feat(timetable): Artist domain — 7 enums + 9 Eloquent models
Enums under App\Enums\Artist\ (PascalCase per FormBuilder convention, snake_case wire values per RFC): - ArtistEngagementStatus (D9, 9 states + Dutch labels) - BumaHandledBy (D26) - FeeType, PaymentStatus - AdvanceSectionType, AdvanceSectionSubmissionStatus, AdvanceSubmissionStatus Models: - Artist (org-scoped, slug-unique-per-org via creating boot hook) - ArtistEngagement (per-event booking, denorm organisation_id) - Genre, Stage (event-scoped, ordered scope), StageDay (Pivot, int PK) - Performance (engagement-scoped, isParked() helper) - AdvanceSection, AdvanceSubmission, ArtistContact (primary scope) OrganisationScope wired: - Direct organisation_id: Artist, Genre, ArtistEngagement - FK-chain via tenantScopeStrategy(): Stage→Event, Performance→Engagement, AdvanceSection→Engagement, AdvanceSubmission→Section→Engagement, ArtistContact→Artist, StageDay→Stage→Event Soft-deletes: Artist, ArtistEngagement, Performance (per RFC §5.4). LogsActivity baseline (logFillable+dontSubmitEmptyLogs) on all business models — actual mutation surfaces wire LogOptions in Session 2+. Inverse relations added on Organisation, Event, Company. companies.handles_buma cast added. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
123
api/app/Models/ArtistEngagement.php
Normal file
123
api/app/Models/ArtistEngagement.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\Artist\ArtistEngagementStatus;
|
||||
use App\Enums\Artist\BumaHandledBy;
|
||||
use App\Enums\Artist\FeeType;
|
||||
use App\Enums\Artist\PaymentStatus;
|
||||
use App\Models\Scopes\OrganisationScope;
|
||||
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;
|
||||
use Spatie\Activitylog\Models\Concerns\LogsActivity;
|
||||
use Spatie\Activitylog\Support\LogOptions;
|
||||
|
||||
final class ArtistEngagement extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasUlids;
|
||||
use LogsActivity;
|
||||
use SoftDeletes;
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
self::addGlobalScope(new OrganisationScope);
|
||||
}
|
||||
|
||||
protected $fillable = [
|
||||
'organisation_id',
|
||||
'artist_id',
|
||||
'event_id',
|
||||
'booking_status',
|
||||
'project_leader_id',
|
||||
'fee_amount',
|
||||
'fee_currency',
|
||||
'fee_type',
|
||||
'buma_applicable',
|
||||
'buma_percentage',
|
||||
'buma_handled_by',
|
||||
'vat_applicable',
|
||||
'vat_percentage',
|
||||
'deal_breakdown',
|
||||
'deposit_percentage',
|
||||
'deposit_due_date',
|
||||
'balance_due_date',
|
||||
'payment_status',
|
||||
'crew_count',
|
||||
'guests_count',
|
||||
'requested_at',
|
||||
'option_expires_at',
|
||||
'advance_open_from',
|
||||
'advance_open_to',
|
||||
'portal_token',
|
||||
'advancing_completed_count',
|
||||
'advancing_total_count',
|
||||
'notes',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'booking_status' => ArtistEngagementStatus::class,
|
||||
'fee_type' => FeeType::class,
|
||||
'buma_handled_by' => BumaHandledBy::class,
|
||||
'payment_status' => PaymentStatus::class,
|
||||
'buma_applicable' => 'boolean',
|
||||
'vat_applicable' => 'boolean',
|
||||
'deal_breakdown' => 'array',
|
||||
'deposit_due_date' => 'date',
|
||||
'balance_due_date' => 'date',
|
||||
'crew_count' => 'integer',
|
||||
'guests_count' => 'integer',
|
||||
'requested_at' => 'datetime',
|
||||
'option_expires_at' => 'datetime',
|
||||
'advance_open_from' => 'datetime',
|
||||
'advance_open_to' => 'datetime',
|
||||
'advancing_completed_count' => 'integer',
|
||||
'advancing_total_count' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logFillable()
|
||||
->dontSubmitEmptyLogs();
|
||||
}
|
||||
|
||||
public function organisation(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Organisation::class);
|
||||
}
|
||||
|
||||
public function artist(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Artist::class);
|
||||
}
|
||||
|
||||
public function event(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Event::class);
|
||||
}
|
||||
|
||||
public function projectLeader(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'project_leader_id');
|
||||
}
|
||||
|
||||
public function performances(): HasMany
|
||||
{
|
||||
return $this->hasMany(Performance::class, 'engagement_id');
|
||||
}
|
||||
|
||||
public function advanceSections(): HasMany
|
||||
{
|
||||
return $this->hasMany(AdvanceSection::class, 'engagement_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user