1
0
forked from metin2/web

Localized and coded character listing, view structure refactoring

This commit is contained in:
2024-12-31 20:33:17 +02:00
parent 103d21b5ef
commit b81cdd512f
11 changed files with 233 additions and 49 deletions

View File

@ -3,8 +3,11 @@
namespace App\Models\Game\Player;
use App\Models\Account;
use App\Models\Enums\CharacterJobEnum;
use App\Models\Game\Highscore\HighscoreCache;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
class Player extends Model
{
@ -60,7 +63,7 @@ class Player extends Model
* @var array<string, string>
*/
protected $casts = [
'job' => CharacterJobEnum::class,
];
/**
@ -70,4 +73,20 @@ class Player extends Model
{
return $this->belongsTo(Account::class, 'account_id', 'id');
}
/**
* Get the index of this player's account
*/
public function index(): BelongsTo
{
return $this->belongsTo(PlayerIndex::class, 'account_id', 'id');
}
/**
* Get this player's ranking
*/
public function highscore(): HasOne
{
return $this->hasOne(HighscoreCache::class, 'name', 'name');
}
}