2024-04-15 23:07:29 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace WoWPress\Models;
|
|
|
|
|
|
|
|
use Wenprise\Eloquent\Model;
|
|
|
|
use WoWPress\Api\BattleNet;
|
|
|
|
|
|
|
|
class Raid extends Model
|
|
|
|
{
|
|
|
|
|
|
|
|
protected $table = "wowpress_raids";
|
|
|
|
public $timestamps = false;
|
|
|
|
protected $primaryKey = 'ID';
|
|
|
|
protected $guarded = ['ID'];
|
|
|
|
|
2024-04-16 15:25:22 +02:00
|
|
|
private $api;
|
|
|
|
|
2024-04-15 23:07:29 +02:00
|
|
|
public function __construct($attrs = [])
|
|
|
|
{
|
|
|
|
parent::__construct($attrs);
|
|
|
|
$options = get_option('wowpress_api');
|
|
|
|
if(isset($options['bnet'])){
|
|
|
|
$key = get_option('wowpress_api')['wowaudit']['key'];
|
|
|
|
}else{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->api = new BattleNet(null,$key);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-16 15:25:22 +02:00
|
|
|
public function getColorAttribute($type=""){
|
|
|
|
switch($this->difficulty){
|
|
|
|
case 'Normal': return "shaman";
|
|
|
|
case 'Heroic': return "warlock";
|
|
|
|
case 'Mythic': return "deathknight";
|
|
|
|
case 'Teamspeak': return "hunter";
|
|
|
|
default: return "priest";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLinkAttribute(){
|
|
|
|
return "/raid/".$this->ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getPreviousAttribute(){
|
|
|
|
$id = $this->ID;
|
|
|
|
while($id){
|
|
|
|
$raid = Raid::find(--$id);
|
|
|
|
if(!empty($raid->ID)){
|
|
|
|
return $raid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getNextAttribute(){
|
|
|
|
$id = $this->ID;
|
|
|
|
while($id <= Raid::max('ID')){
|
|
|
|
$raid = Raid::find(++$id);
|
|
|
|
if(!empty($raid->ID)){
|
|
|
|
return $raid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-04-17 22:10:17 +02:00
|
|
|
public function showSignup(Character $character){
|
|
|
|
require(get_template_directory()."/components/raid-signup.php");
|
|
|
|
}
|
|
|
|
|
2024-04-15 23:07:29 +02:00
|
|
|
}
|