- Crowd Types + Persons CRUD (73 tests) - Festival Sections + Time Slots + Shifts CRUD met assign/claim flow (84 tests) - Invite Flow + Member Management met InvitationService (109 tests) - Schema v1.6 migraties volledig uitgevoerd - DevSeeder bijgewerkt met crowd types voor testorganisatie
97 lines
2.1 KiB
PHP
97 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
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\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
final class Event extends Model
|
|
{
|
|
use HasFactory;
|
|
use HasUlids;
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'organisation_id',
|
|
'name',
|
|
'slug',
|
|
'start_date',
|
|
'end_date',
|
|
'timezone',
|
|
'status',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'start_date' => 'date',
|
|
'end_date' => 'date',
|
|
];
|
|
}
|
|
|
|
public function organisation(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Organisation::class);
|
|
}
|
|
|
|
public function users(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(User::class, 'event_user_roles')
|
|
->withPivot('role')
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function invitations(): HasMany
|
|
{
|
|
return $this->hasMany(UserInvitation::class);
|
|
}
|
|
|
|
public function locations(): HasMany
|
|
{
|
|
return $this->hasMany(Location::class);
|
|
}
|
|
|
|
public function festivalSections(): HasMany
|
|
{
|
|
return $this->hasMany(FestivalSection::class);
|
|
}
|
|
|
|
public function timeSlots(): HasMany
|
|
{
|
|
return $this->hasMany(TimeSlot::class);
|
|
}
|
|
|
|
public function persons(): HasMany
|
|
{
|
|
return $this->hasMany(Person::class);
|
|
}
|
|
|
|
public function crowdLists(): HasMany
|
|
{
|
|
return $this->hasMany(CrowdList::class);
|
|
}
|
|
|
|
public function scopeDraft(Builder $query): Builder
|
|
{
|
|
return $query->where('status', 'draft');
|
|
}
|
|
|
|
public function scopePublished(Builder $query): Builder
|
|
{
|
|
return $query->where('status', 'published');
|
|
}
|
|
|
|
public function scopeActive(Builder $query): Builder
|
|
{
|
|
return $query->whereIn('status', ['showday', 'buildup', 'teardown']);
|
|
}
|
|
}
|