28 lines
588 B
PHP
28 lines
588 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Game\Buildings\BuildingState;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class Building extends Model
|
|
{
|
|
protected $guarded = [];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return ['level' => 'integer', 'priority' => 'integer'];
|
|
}
|
|
|
|
public function village(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Village::class);
|
|
}
|
|
|
|
public function state(): BuildingState
|
|
{
|
|
return new BuildingState($this->id, $this->type, $this->level, $this->priority);
|
|
}
|
|
}
|