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

28 lines
577 B
PHP
Raw Normal View History

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/** Units of one type standing in a village, owned by their home village. */
class UnitStack extends Model
{
protected $guarded = [];
protected function casts(): array
{
return ['count' => 'integer'];
}
public function village(): BelongsTo
{
return $this->belongsTo(Village::class);
}
public function home(): BelongsTo
{
return $this->belongsTo(Village::class, 'home_village_id');
}
}