Files
crewli/api/app/Models/FestivalSection.php

76 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Models;
use App\Models\Scopes\OrganisationScope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Concerns\HasUlids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
final class FestivalSection extends Model
{
use HasFactory;
use HasUlids;
use SoftDeletes;
/** @var string Used by OrganisationScope to determine filtering strategy */
public string $organisationScopeColumn = 'event_id';
protected static function booted(): void
{
static::addGlobalScope(new OrganisationScope());
}
protected $fillable = [
'event_id',
'name',
'category',
'icon',
'type',
'sort_order',
'crew_need',
'crew_auto_accepts',
'crew_invited_to_events',
'added_to_timeline',
'responder_self_checkin',
'crew_accreditation_level',
'public_form_accreditation_level',
'timed_accreditations',
'show_in_registration',
'registration_description',
];
protected function casts(): array
{
return [
'crew_auto_accepts' => 'boolean',
'crew_invited_to_events' => 'boolean',
'added_to_timeline' => 'boolean',
'responder_self_checkin' => 'boolean',
'timed_accreditations' => 'boolean',
'show_in_registration' => 'boolean',
];
}
public function event(): BelongsTo
{
return $this->belongsTo(Event::class);
}
public function shifts(): HasMany
{
return $this->hasMany(Shift::class);
}
public function scopeOrdered(Builder $query): Builder
{
return $query->orderBy('sort_order');
}
}