2026-10-28 18:17:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
2026-10-30 09:47:41 +00:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
2026-10-28 18:17:34 +00:00
|
|
|
|
|
|
|
|
class Player extends Model
|
|
|
|
|
{
|
|
|
|
|
protected $guarded = [];
|
|
|
|
|
|
|
|
|
|
public function user(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(User::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function world(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(World::class);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-30 09:47:41 +00:00
|
|
|
public function membership(): HasOne
|
|
|
|
|
{
|
|
|
|
|
return $this->hasOne(TribeMember::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** The tribe the player belongs to, if any. */
|
|
|
|
|
public function tribeId(): ?int
|
|
|
|
|
{
|
|
|
|
|
return $this->membership?->tribe_id;
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-28 18:17:34 +00:00
|
|
|
public function villages(): HasMany
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(Village::class);
|
|
|
|
|
}
|
|
|
|
|
}
|