Eight factories with named states (Genre, Artist, ArtistContact, Stage, ArtistEngagement, Performance, AdvanceSection, AdvanceSubmission). ArtistTimetableDevSeeder hooked into DevSeeder::seedEchtFeesten after the form-builder showcase. Produces: - 4 stages (Mainstage, Havana, Stairway, Socialite) with prototype-style hex colours - 4 stages × 3 sub-events = 12 stage_days rows - 4 genres (Hardstyle, Techno, Indie, Live band) - 6 master artists, each with one tour-manager ArtistContact - 12 engagements with status mix (1 Draft, 2 Requested, 3 Option, 2 Confirmed, 3 Contracted, 1 Cancelled). Two artists have two engagements each (different sub-events) — exercises D17 multi- engagement-per-artist. - 13 performances, including one parked (stage_id=null = wachtrij) and one B2B pair within 3 minutes on Mainstage Saturday to seed the Session 4 frontend B2B detector. Also fix LogOptions method name across 8 models: dontSubmitEmptyLogs() → dontLogEmptyChanges() (Spatie's actual API; surfaced when DevSeeder ran). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
108 lines
2.6 KiB
PHP
108 lines
2.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
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 Illuminate\Support\Str;
|
|
use Spatie\Activitylog\Models\Concerns\LogsActivity;
|
|
use Spatie\Activitylog\Support\LogOptions;
|
|
|
|
final class Artist extends Model
|
|
{
|
|
use HasFactory;
|
|
use HasUlids;
|
|
use LogsActivity;
|
|
use SoftDeletes;
|
|
|
|
protected static function booted(): void
|
|
{
|
|
self::addGlobalScope(new OrganisationScope);
|
|
|
|
self::creating(function (Artist $artist): void {
|
|
if (empty($artist->slug)) {
|
|
$artist->slug = $artist->generateUniqueSlug($artist->name);
|
|
}
|
|
});
|
|
}
|
|
|
|
protected $fillable = [
|
|
'organisation_id',
|
|
'name',
|
|
'slug',
|
|
'default_genre_id',
|
|
'default_draw',
|
|
'star_rating',
|
|
'home_base_country',
|
|
'agent_company_id',
|
|
'notes',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'default_draw' => 'integer',
|
|
'star_rating' => 'integer',
|
|
];
|
|
}
|
|
|
|
public function getActivitylogOptions(): LogOptions
|
|
{
|
|
return LogOptions::defaults()
|
|
->logFillable()
|
|
->dontLogEmptyChanges();
|
|
}
|
|
|
|
private function generateUniqueSlug(string $name): string
|
|
{
|
|
$base = Str::slug($name);
|
|
$slug = $base;
|
|
$suffix = 2;
|
|
|
|
while (
|
|
self::withoutGlobalScope(OrganisationScope::class)
|
|
->withTrashed()
|
|
->where('organisation_id', $this->organisation_id)
|
|
->where('slug', $slug)
|
|
->exists()
|
|
) {
|
|
$slug = "{$base}-{$suffix}";
|
|
$suffix++;
|
|
}
|
|
|
|
return $slug;
|
|
}
|
|
|
|
public function organisation(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Organisation::class);
|
|
}
|
|
|
|
public function defaultGenre(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Genre::class, 'default_genre_id');
|
|
}
|
|
|
|
public function agentCompany(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Company::class, 'agent_company_id');
|
|
}
|
|
|
|
public function contacts(): HasMany
|
|
{
|
|
return $this->hasMany(ArtistContact::class);
|
|
}
|
|
|
|
public function engagements(): HasMany
|
|
{
|
|
return $this->hasMany(ArtistEngagement::class);
|
|
}
|
|
}
|