feat: fase 2 backend — crowd types, persons, sections, shifts, invite flow
- 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
This commit is contained in:
26
api/database/factories/CompanyFactory.php
Normal file
26
api/database/factories/CompanyFactory.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\Organisation;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/** @extends Factory<Company> */
|
||||
final class CompanyFactory extends Factory
|
||||
{
|
||||
/** @return array<string, mixed> */
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'organisation_id' => Organisation::factory(),
|
||||
'name' => fake('nl_NL')->company(),
|
||||
'type' => fake()->randomElement(['supplier', 'partner', 'agency', 'venue', 'other']),
|
||||
'contact_name' => fake('nl_NL')->name(),
|
||||
'contact_email' => fake()->companyEmail(),
|
||||
'contact_phone' => fake('nl_NL')->phoneNumber(),
|
||||
];
|
||||
}
|
||||
}
|
||||
50
api/database/factories/CrowdTypeFactory.php
Normal file
50
api/database/factories/CrowdTypeFactory.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\CrowdType;
|
||||
use App\Models\Organisation;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/** @extends Factory<CrowdType> */
|
||||
final class CrowdTypeFactory extends Factory
|
||||
{
|
||||
private const TYPES = [
|
||||
'CREW' => ['name' => 'Crew', 'color' => '#3b82f6'],
|
||||
'VOLUNTEER' => ['name' => 'Vrijwilliger', 'color' => '#10b981'],
|
||||
'ARTIST' => ['name' => 'Artiest', 'color' => '#8b5cf6'],
|
||||
'GUEST' => ['name' => 'Gast', 'color' => '#f59e0b'],
|
||||
'PRESS' => ['name' => 'Pers', 'color' => '#6366f1'],
|
||||
'PARTNER' => ['name' => 'Partner', 'color' => '#ec4899'],
|
||||
'SUPPLIER' => ['name' => 'Leverancier', 'color' => '#64748b'],
|
||||
];
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
public function definition(): array
|
||||
{
|
||||
$systemType = fake()->randomElement(array_keys(self::TYPES));
|
||||
$typeConfig = self::TYPES[$systemType];
|
||||
|
||||
return [
|
||||
'organisation_id' => Organisation::factory(),
|
||||
'name' => $typeConfig['name'],
|
||||
'system_type' => $systemType,
|
||||
'color' => $typeConfig['color'],
|
||||
'icon' => null,
|
||||
'is_active' => true,
|
||||
];
|
||||
}
|
||||
|
||||
public function systemType(string $type): static
|
||||
{
|
||||
$config = self::TYPES[$type];
|
||||
|
||||
return $this->state(fn () => [
|
||||
'system_type' => $type,
|
||||
'name' => $config['name'],
|
||||
'color' => $config['color'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
43
api/database/factories/FestivalSectionFactory.php
Normal file
43
api/database/factories/FestivalSectionFactory.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\FestivalSection;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/** @extends Factory<FestivalSection> */
|
||||
final class FestivalSectionFactory extends Factory
|
||||
{
|
||||
/** @return array<string, mixed> */
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'event_id' => Event::factory(),
|
||||
'name' => fake()->randomElement([
|
||||
'Horeca',
|
||||
'Backstage',
|
||||
'Overig',
|
||||
'Entertainment',
|
||||
'Security',
|
||||
'Techniek',
|
||||
]),
|
||||
'type' => 'standard',
|
||||
'sort_order' => fake()->numberBetween(1, 5),
|
||||
'responder_self_checkin' => true,
|
||||
'crew_auto_accepts' => false,
|
||||
];
|
||||
}
|
||||
|
||||
public function withSortOrder(int $order): static
|
||||
{
|
||||
return $this->state(fn () => ['sort_order' => $order]);
|
||||
}
|
||||
|
||||
public function crossEvent(): static
|
||||
{
|
||||
return $this->state(fn () => ['type' => 'cross_event']);
|
||||
}
|
||||
}
|
||||
34
api/database/factories/LocationFactory.php
Normal file
34
api/database/factories/LocationFactory.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\Location;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/** @extends Factory<Location> */
|
||||
final class LocationFactory extends Factory
|
||||
{
|
||||
/** @return array<string, mixed> */
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'event_id' => Event::factory(),
|
||||
'name' => fake()->randomElement([
|
||||
'Hoofdpodium',
|
||||
'Bar Noord',
|
||||
'Bar Zuid',
|
||||
'Security Gate A',
|
||||
'Backstage',
|
||||
'Hospitality Tent',
|
||||
]),
|
||||
'address' => null,
|
||||
'lat' => null,
|
||||
'lng' => null,
|
||||
'description' => null,
|
||||
'access_instructions' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
34
api/database/factories/PersonFactory.php
Normal file
34
api/database/factories/PersonFactory.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\CrowdType;
|
||||
use App\Models\Event;
|
||||
use App\Models\Person;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/** @extends Factory<Person> */
|
||||
final class PersonFactory extends Factory
|
||||
{
|
||||
/** @return array<string, mixed> */
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'event_id' => Event::factory(),
|
||||
'crowd_type_id' => CrowdType::factory(),
|
||||
'name' => fake('nl_NL')->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'phone' => fake('nl_NL')->phoneNumber(),
|
||||
'status' => 'pending',
|
||||
'is_blacklisted' => false,
|
||||
'custom_fields' => null,
|
||||
];
|
||||
}
|
||||
|
||||
public function approved(): static
|
||||
{
|
||||
return $this->state(fn () => ['status' => 'approved']);
|
||||
}
|
||||
}
|
||||
52
api/database/factories/ShiftFactory.php
Normal file
52
api/database/factories/ShiftFactory.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\FestivalSection;
|
||||
use App\Models\Shift;
|
||||
use App\Models\TimeSlot;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/** @extends Factory<Shift> */
|
||||
final class ShiftFactory extends Factory
|
||||
{
|
||||
/** @return array<string, mixed> */
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'festival_section_id' => FestivalSection::factory(),
|
||||
'time_slot_id' => TimeSlot::factory(),
|
||||
'title' => fake()->randomElement([
|
||||
'Tapper',
|
||||
'Tussenbuffet',
|
||||
'Barhoofd',
|
||||
'Stage Manager',
|
||||
'Stagehand',
|
||||
'Coördinator',
|
||||
'Runner',
|
||||
]),
|
||||
'slots_total' => fake()->numberBetween(1, 10),
|
||||
'slots_open_for_claiming' => 0,
|
||||
'status' => 'draft',
|
||||
'is_lead_role' => false,
|
||||
'allow_overlap' => false,
|
||||
];
|
||||
}
|
||||
|
||||
public function open(): static
|
||||
{
|
||||
return $this->state(fn () => ['status' => 'open']);
|
||||
}
|
||||
|
||||
public function withClaiming(int $slots): static
|
||||
{
|
||||
return $this->state(fn () => ['slots_open_for_claiming' => $slots]);
|
||||
}
|
||||
|
||||
public function allowOverlap(): static
|
||||
{
|
||||
return $this->state(fn () => ['allow_overlap' => true]);
|
||||
}
|
||||
}
|
||||
33
api/database/factories/TimeSlotFactory.php
Normal file
33
api/database/factories/TimeSlotFactory.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\TimeSlot;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/** @extends Factory<TimeSlot> */
|
||||
final class TimeSlotFactory extends Factory
|
||||
{
|
||||
/** @return array<string, mixed> */
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'event_id' => Event::factory(),
|
||||
'name' => fake()->randomElement([
|
||||
'Vrijdag Avond',
|
||||
'Zaterdag Dag',
|
||||
'Zaterdag Avond',
|
||||
'Zondag',
|
||||
'Opbouw',
|
||||
]),
|
||||
'person_type' => 'VOLUNTEER',
|
||||
'date' => fake()->dateTimeBetween('+1 month', '+3 months'),
|
||||
'start_time' => '18:00:00',
|
||||
'end_time' => '02:00:00',
|
||||
'duration_hours' => 8.00,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('locations', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('event_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('address')->nullable();
|
||||
$table->decimal('lat', 10, 8)->nullable();
|
||||
$table->decimal('lng', 11, 8)->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->text('access_instructions')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('event_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('locations');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('festival_sections', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('event_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->unsignedInteger('sort_order')->default(0);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['event_id', 'sort_order']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('festival_sections');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('time_slots', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('event_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->enum('person_type', ['CREW', 'VOLUNTEER', 'PRESS', 'PHOTO', 'PARTNER'])->default('VOLUNTEER');
|
||||
$table->date('date');
|
||||
$table->time('start_time');
|
||||
$table->time('end_time');
|
||||
$table->decimal('duration_hours', 4, 2)->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['event_id', 'person_type', 'date']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('time_slots');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('events', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('events', 'volunteer_min_hours_for_pass')) {
|
||||
$table->dropColumn('volunteer_min_hours_for_pass');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('events', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('events', 'volunteer_min_hours_for_pass')) {
|
||||
$table->decimal('volunteer_min_hours_for_pass', 4, 2)->nullable()->after('status');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('locations', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('locations', 'route_geojson')) {
|
||||
$table->dropColumn('route_geojson');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('locations', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('locations', 'route_geojson')) {
|
||||
$table->json('route_geojson')->nullable()->after('access_instructions');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('festival_sections', function (Blueprint $table) {
|
||||
$table->enum('type', ['standard', 'cross_event'])->default('standard')->after('name');
|
||||
$table->unsignedInteger('crew_need')->nullable()->after('type');
|
||||
$table->boolean('crew_auto_accepts')->default(false)->after('sort_order');
|
||||
$table->boolean('crew_invited_to_events')->default(false)->after('crew_auto_accepts');
|
||||
$table->boolean('added_to_timeline')->default(false)->after('crew_invited_to_events');
|
||||
$table->boolean('responder_self_checkin')->default(true)->after('added_to_timeline');
|
||||
$table->string('crew_accreditation_level')->nullable()->after('responder_self_checkin');
|
||||
$table->string('public_form_accreditation_level')->nullable()->after('crew_accreditation_level');
|
||||
$table->boolean('timed_accreditations')->default(false)->after('public_form_accreditation_level');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('festival_sections', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'type',
|
||||
'crew_need',
|
||||
'crew_auto_accepts',
|
||||
'crew_invited_to_events',
|
||||
'added_to_timeline',
|
||||
'responder_self_checkin',
|
||||
'crew_accreditation_level',
|
||||
'public_form_accreditation_level',
|
||||
'timed_accreditations',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('shifts', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('festival_section_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('time_slot_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('location_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->time('report_time')->nullable();
|
||||
$table->string('title')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->text('instructions')->nullable();
|
||||
$table->text('coordinator_notes')->nullable();
|
||||
$table->unsignedInteger('slots_total');
|
||||
$table->unsignedInteger('slots_open_for_claiming');
|
||||
$table->boolean('is_lead_role')->default(false);
|
||||
$table->time('actual_start_time')->nullable();
|
||||
$table->time('actual_end_time')->nullable();
|
||||
$table->date('end_date')->nullable();
|
||||
$table->boolean('allow_overlap')->default(false);
|
||||
$table->json('events_during_shift')->nullable();
|
||||
$table->enum('status', ['draft', 'open', 'full', 'in_progress', 'completed', 'cancelled'])->default('draft');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['festival_section_id', 'time_slot_id']);
|
||||
$table->index(['time_slot_id', 'status']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('shifts');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('shift_assignments', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('shift_id')->constrained()->cascadeOnDelete();
|
||||
$table->char('person_id', 26);
|
||||
$table->foreignUlid('time_slot_id')->constrained()->cascadeOnDelete();
|
||||
$table->enum('status', ['pending_approval', 'approved', 'rejected', 'cancelled', 'completed'])->default('pending_approval');
|
||||
$table->boolean('auto_approved')->default(false);
|
||||
$table->foreignUlid('assigned_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamp('assigned_at')->nullable();
|
||||
$table->foreignUlid('approved_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamp('approved_at')->nullable();
|
||||
$table->text('rejection_reason')->nullable();
|
||||
$table->decimal('hours_expected', 4, 2)->nullable();
|
||||
$table->decimal('hours_completed', 4, 2)->nullable();
|
||||
$table->timestamp('checked_in_at')->nullable();
|
||||
$table->timestamp('checked_out_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['person_id', 'time_slot_id']);
|
||||
$table->index(['shift_id', 'status']);
|
||||
$table->index(['person_id', 'status']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('shift_assignments');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('shift_check_ins', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('shift_assignment_id')->constrained()->cascadeOnDelete();
|
||||
$table->char('person_id', 26);
|
||||
$table->foreignUlid('shift_id')->constrained()->cascadeOnDelete();
|
||||
$table->timestamp('checked_in_at');
|
||||
$table->timestamp('checked_out_at')->nullable();
|
||||
$table->foreignUlid('checked_in_by_user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->enum('method', ['qr', 'manual']);
|
||||
|
||||
$table->index('shift_assignment_id');
|
||||
$table->index(['shift_id', 'checked_in_at']);
|
||||
$table->index(['person_id', 'checked_in_at']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('shift_check_ins');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('volunteer_availabilities', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->char('person_id', 26);
|
||||
$table->foreignUlid('time_slot_id')->constrained()->cascadeOnDelete();
|
||||
$table->tinyInteger('preference_level')->default(3);
|
||||
$table->timestamp('submitted_at');
|
||||
|
||||
$table->unique(['person_id', 'time_slot_id']);
|
||||
$table->index('time_slot_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('volunteer_availabilities');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('artists', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('event_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->enum('booking_status', ['concept', 'requested', 'option', 'confirmed', 'contracted', 'cancelled'])->default('concept');
|
||||
$table->tinyInteger('star_rating')->default(1);
|
||||
$table->foreignUlid('project_leader_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->boolean('milestone_offer_in')->default(false);
|
||||
$table->boolean('milestone_offer_agreed')->default(false);
|
||||
$table->boolean('milestone_confirmed')->default(false);
|
||||
$table->boolean('milestone_announced')->default(false);
|
||||
$table->boolean('milestone_schedule_confirmed')->default(false);
|
||||
$table->boolean('milestone_itinerary_sent')->default(false);
|
||||
$table->boolean('milestone_advance_sent')->default(false);
|
||||
$table->boolean('milestone_advance_received')->default(false);
|
||||
$table->datetime('advance_open_from')->nullable();
|
||||
$table->datetime('advance_open_to')->nullable();
|
||||
$table->boolean('show_advance_share_page')->default(true);
|
||||
$table->char('portal_token', 26)->unique();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('event_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('artists');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('advance_sections', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('artist_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->enum('type', ['guest_list', 'contacts', 'production', 'custom']);
|
||||
$table->boolean('is_open')->default(false);
|
||||
$table->datetime('open_from')->nullable();
|
||||
$table->datetime('open_to')->nullable();
|
||||
$table->unsignedInteger('sort_order')->default(0);
|
||||
$table->enum('submission_status', ['open', 'pending', 'submitted', 'approved', 'declined'])->default('open');
|
||||
$table->timestamp('last_submitted_at')->nullable();
|
||||
$table->string('last_submitted_by')->nullable();
|
||||
$table->json('submission_diff')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['artist_id', 'is_open']);
|
||||
$table->index(['artist_id', 'submission_status']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('advance_sections');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('crowd_types', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('organisation_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->enum('system_type', ['CREW', 'GUEST', 'ARTIST', 'VOLUNTEER', 'PRESS', 'PARTNER', 'SUPPLIER']);
|
||||
$table->string('color')->default('#6366f1');
|
||||
$table->string('icon')->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['organisation_id', 'system_type']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('crowd_types');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('companies', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('organisation_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->enum('type', ['supplier', 'partner', 'agency', 'venue', 'other']);
|
||||
$table->string('contact_name')->nullable();
|
||||
$table->string('contact_email')->nullable();
|
||||
$table->string('contact_phone')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('organisation_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('companies');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('persons', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('user_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignUlid('event_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('crowd_type_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('company_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('email');
|
||||
$table->string('phone')->nullable();
|
||||
$table->enum('status', ['invited', 'applied', 'pending', 'approved', 'rejected', 'no_show'])->default('pending');
|
||||
$table->boolean('is_blacklisted')->default(false);
|
||||
$table->text('admin_notes')->nullable();
|
||||
$table->json('custom_fields')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['event_id', 'crowd_type_id', 'status']);
|
||||
$table->index(['email', 'event_id']);
|
||||
$table->index(['user_id', 'event_id']);
|
||||
});
|
||||
|
||||
// Conditional unique: one user can only appear once per event
|
||||
// MySQL doesn't support partial indexes, so we use a unique index
|
||||
// that only fires when user_id is not null (handled at application level)
|
||||
// The composite index (user_id, event_id) already exists above
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('persons');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('crowd_lists', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('event_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('crowd_type_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->enum('type', ['internal', 'external']);
|
||||
$table->foreignUlid('recipient_company_id')->nullable()->constrained('companies')->nullOnDelete();
|
||||
$table->boolean('auto_approve')->default(false);
|
||||
$table->unsignedInteger('max_persons')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['event_id', 'type']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('crowd_lists');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('crowd_list_persons', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignUlid('crowd_list_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('person_id')->constrained('persons')->cascadeOnDelete();
|
||||
$table->timestamp('added_at');
|
||||
$table->foreignUlid('added_by_user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
|
||||
$table->unique(['crowd_list_id', 'person_id']);
|
||||
$table->index('person_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('crowd_list_persons');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('shift_assignments', function (Blueprint $table) {
|
||||
$table->foreign('person_id')->references('id')->on('persons')->cascadeOnDelete();
|
||||
});
|
||||
|
||||
Schema::table('shift_check_ins', function (Blueprint $table) {
|
||||
$table->foreign('person_id')->references('id')->on('persons')->cascadeOnDelete();
|
||||
});
|
||||
|
||||
Schema::table('volunteer_availabilities', function (Blueprint $table) {
|
||||
$table->foreign('person_id')->references('id')->on('persons')->cascadeOnDelete();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('shift_assignments', function (Blueprint $table) {
|
||||
$table->dropForeign(['person_id']);
|
||||
});
|
||||
|
||||
Schema::table('shift_check_ins', function (Blueprint $table) {
|
||||
$table->dropForeign(['person_id']);
|
||||
});
|
||||
|
||||
Schema::table('volunteer_availabilities', function (Blueprint $table) {
|
||||
$table->dropForeign(['person_id']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// Add assigned_crew_id to shifts
|
||||
Schema::table('shifts', function (Blueprint $table) {
|
||||
$table->foreignUlid('assigned_crew_id')->nullable()->after('allow_overlap')->constrained('users')->nullOnDelete();
|
||||
});
|
||||
|
||||
// Shift waitlist
|
||||
Schema::create('shift_waitlist', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('shift_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('person_id')->constrained('persons')->cascadeOnDelete();
|
||||
$table->unsignedInteger('position');
|
||||
$table->timestamp('added_at');
|
||||
$table->timestamp('notified_at')->nullable();
|
||||
|
||||
$table->unique(['shift_id', 'person_id']);
|
||||
$table->index(['shift_id', 'position']);
|
||||
});
|
||||
|
||||
// Shift absences
|
||||
Schema::create('shift_absences', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('shift_assignment_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('person_id')->constrained('persons')->cascadeOnDelete();
|
||||
$table->enum('reason', ['sick', 'personal', 'other']);
|
||||
$table->timestamp('reported_at');
|
||||
$table->enum('status', ['open', 'filled', 'closed'])->default('open');
|
||||
$table->timestamp('closed_at')->nullable();
|
||||
|
||||
$table->index('shift_assignment_id');
|
||||
$table->index('status');
|
||||
});
|
||||
|
||||
// Shift swap requests
|
||||
Schema::create('shift_swap_requests', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('from_assignment_id')->constrained('shift_assignments')->cascadeOnDelete();
|
||||
$table->foreignUlid('to_person_id')->constrained('persons')->cascadeOnDelete();
|
||||
$table->text('message')->nullable();
|
||||
$table->enum('status', ['pending', 'accepted', 'rejected', 'cancelled', 'completed'])->default('pending');
|
||||
$table->foreignUlid('reviewed_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamp('reviewed_at')->nullable();
|
||||
$table->boolean('auto_approved')->default(false);
|
||||
|
||||
$table->index('from_assignment_id');
|
||||
$table->index(['to_person_id', 'status']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('shift_swap_requests');
|
||||
Schema::dropIfExists('shift_absences');
|
||||
Schema::dropIfExists('shift_waitlist');
|
||||
|
||||
Schema::table('shifts', function (Blueprint $table) {
|
||||
$table->dropForeign(['assigned_crew_id']);
|
||||
$table->dropColumn('assigned_crew_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Drop the UNIQUE(person_id, time_slot_id) constraint on shift_assignments.
|
||||
*
|
||||
* Reason: shifts.allow_overlap = true must allow a person to be assigned
|
||||
* to multiple shifts in the same time slot. MySQL doesn't support partial
|
||||
* unique indexes, so conflict detection is handled in application code.
|
||||
*
|
||||
* @see SCHEMA.md section 3.5.3 — shift_assignments
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('shift_assignments', function (Blueprint $table) {
|
||||
$table->dropUnique(['person_id', 'time_slot_id']);
|
||||
// Keep the composite index for query performance
|
||||
$table->index(['person_id', 'time_slot_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('shift_assignments', function (Blueprint $table) {
|
||||
$table->dropIndex(['person_id', 'time_slot_id']);
|
||||
$table->unique(['person_id', 'time_slot_id']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\CrowdType;
|
||||
use App\Models\Organisation;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
@@ -76,5 +77,27 @@ class DevSeeder extends Seeder
|
||||
if (!$org->users()->where('user_id', $member->id)->exists()) {
|
||||
$org->users()->attach($member, ['role' => 'org_member']);
|
||||
}
|
||||
|
||||
// 4. Default Crowd Types for Test Festival BV
|
||||
$crowdTypes = [
|
||||
['name' => 'Crew', 'system_type' => 'CREW', 'color' => '#3b82f6'],
|
||||
['name' => 'Vrijwilliger', 'system_type' => 'VOLUNTEER', 'color' => '#10b981'],
|
||||
['name' => 'Artiest', 'system_type' => 'ARTIST', 'color' => '#8b5cf6'],
|
||||
['name' => 'Gast', 'system_type' => 'GUEST', 'color' => '#f59e0b'],
|
||||
['name' => 'Pers', 'system_type' => 'PRESS', 'color' => '#6366f1'],
|
||||
];
|
||||
|
||||
foreach ($crowdTypes as $ct) {
|
||||
CrowdType::firstOrCreate(
|
||||
[
|
||||
'organisation_id' => $org->id,
|
||||
'system_type' => $ct['system_type'],
|
||||
],
|
||||
[
|
||||
'name' => $ct['name'],
|
||||
'color' => $ct['color'],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user