74 lines
1.6 KiB
PHP
74 lines
1.6 KiB
PHP
<?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'];
|
|
|
|
private $api;
|
|
|
|
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);
|
|
}
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
public function showSignup(Character $character){
|
|
require(get_template_directory()."/components/raid-signup.php");
|
|
}
|
|
|
|
} |