game-village-politics-backend/app/Models/Tribe.php

40 lines
918 B
PHP
Raw Normal View History

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Tribe extends Model
{
protected $guarded = [];
public function world(): BelongsTo
{
return $this->belongsTo(World::class);
}
public function members(): HasMany
{
return $this->hasMany(TribeMember::class)->orderBy('id');
}
public function invites(): HasMany
{
return $this->hasMany(TribeInvite::class)->orderBy('id');
}
/** What this tribe holds towards others. */
public function relations(): HasMany
{
return $this->hasMany(TribeRelation::class);
}
/** @return array{id: int, name: string, tag: string} */
public function summary(): array
{
return ['id' => $this->id, 'name' => $this->name, 'tag' => $this->tag];
}
}