Files
crewli/api/app/Console/Commands/SeedArtistAdvanceDefaultCommand.php
bert.hausmans 895a1690e7 feat(timetable): ArtistAdvanceDefault seeder + bootstrap
Seeds 5 default sections per RFC v0.2 D15 (General Info, Contacts,
Production, Technical Rider, Hospitality) on a per-organisation
artist_advance FormSchema with section_level_submit=true. Each
section ships with 3-4 illustrative form_fields; organisations
customise via the FormBuilder UI later.

Wired into org-creation via the new OrganisationObserver so new
tenants receive the schema automatically. Existing orgs get
coverage via the new artist:seed-advance-default artisan command
(idempotent — orgs that already own a schema are skipped).

Note: introduces a new production-grade default-seeder convention.
Prior FormBuilder defaults were dev-only via FormBuilderDevSeeder
called from DevSeeder::run(). This is the first non-dev path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 22:16:25 +02:00

52 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Console\Commands;
use App\FormBuilder\Defaults\ArtistAdvanceDefault;
use App\Models\Organisation;
use Illuminate\Console\Command;
/**
* Seed the default artist_advance FormSchema for one organisation
* (by id) or for every organisation.
*
* The OrganisationObserver wires this for new tenants automatically;
* this command exists to backfill organisations that pre-date the
* RFC-TIMETABLE v0.2 D15 default. Idempotent — orgs that already own
* an artist_advance schema are skipped.
*/
final class SeedArtistAdvanceDefaultCommand extends Command
{
protected $signature = 'artist:seed-advance-default {organisation? : Organisation ID; omit to seed every organisation}';
protected $description = 'Seed the default artist_advance FormSchema for one or every organisation.';
public function handle(): int
{
$organisationId = $this->argument('organisation');
$query = Organisation::query();
if (is_string($organisationId) && $organisationId !== '') {
$query->whereKey($organisationId);
}
$organisations = $query->get();
if ($organisations->isEmpty()) {
$this->error('No organisations matched the supplied filter.');
return self::FAILURE;
}
foreach ($organisations as $organisation) {
ArtistAdvanceDefault::seedFor($organisation);
$this->line(sprintf(' ✓ %s (%s)', $organisation->name, $organisation->id));
}
$this->info(sprintf('Seeded artist_advance defaults for %d organisation(s).', $organisations->count()));
return self::SUCCESS;
}
}