64 lines
1.3 KiB
PHP
64 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class Field extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'location',
|
|
'description',
|
|
'status',
|
|
'capacity',
|
|
'surface_type',
|
|
'indoor',
|
|
'dimensions',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be cast.
|
|
*
|
|
* @var array<string, string>
|
|
*/
|
|
protected $casts = [
|
|
'indoor' => 'boolean',
|
|
'dimensions' => 'array',
|
|
];
|
|
|
|
/**
|
|
* Get the competitions that use this field.
|
|
*/
|
|
public function competitions(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Competition::class)
|
|
->withTimestamps();
|
|
}
|
|
|
|
/**
|
|
* Get the matches scheduled on this field.
|
|
*/
|
|
public function matches(): HasMany
|
|
{
|
|
return $this->hasMany(MatchGame::class);
|
|
}
|
|
|
|
/**
|
|
* Get the break periods scheduled on this field.
|
|
*/
|
|
public function breakPeriods(): HasMany
|
|
{
|
|
return $this->hasMany(BreakPeriod::class);
|
|
}
|
|
}
|