init commit
This commit is contained in:
commit
c9d982669a
461 changed files with 30317 additions and 0 deletions
90
app/Models/Competition.php
Normal file
90
app/Models/Competition.php
Normal file
|
@ -0,0 +1,90 @@
|
|||
<?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 Competition extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'description',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'status',
|
||||
'location',
|
||||
'max_teams',
|
||||
'current_scheduling_mode_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the teams participating in the competition.
|
||||
*/
|
||||
public function teams(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Team::class)
|
||||
->withTimestamps()
|
||||
->withPivot('status');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the scheduling modes available for this competition.
|
||||
*/
|
||||
public function schedulingModes(): HasMany
|
||||
{
|
||||
return $this->hasMany(SchedulingMode::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current scheduling mode for this competition.
|
||||
*/
|
||||
public function currentSchedulingMode()
|
||||
{
|
||||
return $this->belongsTo(SchedulingMode::class, 'current_scheduling_mode_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the matches for this competition.
|
||||
*/
|
||||
public function matches(): HasMany
|
||||
{
|
||||
return $this->hasMany(MatchGame::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the break periods for this competition.
|
||||
*/
|
||||
public function breakPeriods(): HasMany
|
||||
{
|
||||
return $this->hasMany(BreakPeriod::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields used in this competition.
|
||||
*/
|
||||
public function fields(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Field::class)
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue