WowPress-Tailwind/theme/wowpress/Models/SKS.php

42 lines
882 B
PHP

<?php
namespace WoWPress\Models;
use Wenprise\Eloquent\Model;
use WoWPress\Api\BattleNet;
class SKS extends Model
{
protected $table = "wowpress_sks";
public $timestamps = false;
protected $primaryKey = 'ID';
protected $guarded = ['ID'];
public static function getList($name){
return static::where('list_name',$name)->orderBy('rank')->get();
}
public static function getLists(){
return static::distinct('list_name')->get();
}
public function getCharacterAttribute(){
$char= Character::where('name',$this->char_name)->where('realm',$this->realm_name)->first();
if(!empty($char->ID)){
return $char;
}
$char = new Character();
$char->name = $this->char_name;
$char->realm = $this->realm_name;
$char->class = "yellow";
return $char;
}
}