refactor: align codebase with EventCrew domain and trim legacy band stack
- Update API: events, users, policies, routes, resources, migrations - Remove deprecated models/resources (customers, setlists, invitations, etc.) - Refresh admin app and docs; remove apps/band Made-with: Cursor
This commit is contained in:
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Customer>
|
||||
*/
|
||||
final class CustomerFactory extends Factory
|
||||
{
|
||||
protected $model = Customer::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
$type = fake()->randomElement(['individual', 'company']);
|
||||
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'company_name' => $type === 'company' ? fake()->company() : null,
|
||||
'type' => $type,
|
||||
'email' => fake()->optional()->safeEmail(),
|
||||
'phone' => fake()->optional()->phoneNumber(),
|
||||
'address' => fake()->optional()->streetAddress(),
|
||||
'city' => fake()->optional()->city(),
|
||||
'postal_code' => fake()->optional()->postcode(),
|
||||
'country' => 'NL',
|
||||
'notes' => fake()->optional()->paragraph(),
|
||||
'is_portal_enabled' => fake()->boolean(20),
|
||||
];
|
||||
}
|
||||
|
||||
public function individual(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'type' => 'individual',
|
||||
'company_name' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function company(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'type' => 'company',
|
||||
'company_name' => fake()->company(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function withPortal(): static
|
||||
{
|
||||
return $this->state(fn () => ['is_portal_enabled' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,100 +4,32 @@ declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\EventStatus;
|
||||
use App\Enums\EventVisibility;
|
||||
use App\Models\Customer;
|
||||
use App\Models\Event;
|
||||
use App\Models\Location;
|
||||
use App\Models\User;
|
||||
use App\Models\Organisation;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Event>
|
||||
*/
|
||||
/** @extends Factory<Event> */
|
||||
final class EventFactory extends Factory
|
||||
{
|
||||
protected $model = Event::class;
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
public function definition(): array
|
||||
{
|
||||
$startTime = fake()->time('H:i');
|
||||
$endTime = fake()->optional()->time('H:i');
|
||||
$name = fake()->unique()->words(3, true);
|
||||
$startDate = fake()->dateTimeBetween('+1 week', '+3 months');
|
||||
|
||||
return [
|
||||
'title' => fake()->sentence(3),
|
||||
'description' => fake()->optional()->paragraph(),
|
||||
'event_date' => fake()->dateTimeBetween('+1 week', '+6 months'),
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime,
|
||||
'fee' => fake()->optional()->randomFloat(2, 100, 5000),
|
||||
'currency' => 'EUR',
|
||||
'status' => fake()->randomElement(EventStatus::cases()),
|
||||
'visibility' => EventVisibility::Members,
|
||||
'notes' => fake()->optional()->paragraph(),
|
||||
'created_by' => User::factory(),
|
||||
'organisation_id' => Organisation::factory(),
|
||||
'name' => ucfirst($name),
|
||||
'slug' => str($name)->slug()->toString(),
|
||||
'start_date' => $startDate,
|
||||
'end_date' => fake()->dateTimeBetween($startDate, (clone $startDate)->modify('+3 days')),
|
||||
'timezone' => 'Europe/Amsterdam',
|
||||
'status' => 'draft',
|
||||
];
|
||||
}
|
||||
|
||||
public function draft(): static
|
||||
public function published(): static
|
||||
{
|
||||
return $this->state(fn () => ['status' => EventStatus::Draft]);
|
||||
}
|
||||
|
||||
public function pending(): static
|
||||
{
|
||||
return $this->state(fn () => ['status' => EventStatus::Pending]);
|
||||
}
|
||||
|
||||
public function confirmed(): static
|
||||
{
|
||||
return $this->state(fn () => ['status' => EventStatus::Confirmed]);
|
||||
}
|
||||
|
||||
public function completed(): static
|
||||
{
|
||||
return $this->state(fn () => ['status' => EventStatus::Completed]);
|
||||
}
|
||||
|
||||
public function cancelled(): static
|
||||
{
|
||||
return $this->state(fn () => ['status' => EventStatus::Cancelled]);
|
||||
}
|
||||
|
||||
public function withLocation(): static
|
||||
{
|
||||
return $this->state(fn () => ['location_id' => Location::factory()]);
|
||||
}
|
||||
|
||||
public function withCustomer(): static
|
||||
{
|
||||
return $this->state(fn () => ['customer_id' => Customer::factory()]);
|
||||
}
|
||||
|
||||
public function upcoming(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'event_date' => fake()->dateTimeBetween('+1 day', '+1 month'),
|
||||
'status' => EventStatus::Confirmed,
|
||||
]);
|
||||
}
|
||||
|
||||
public function past(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'event_date' => fake()->dateTimeBetween('-6 months', '-1 day'),
|
||||
'status' => EventStatus::Completed,
|
||||
]);
|
||||
}
|
||||
|
||||
public function privateEvent(): static
|
||||
{
|
||||
return $this->state(fn () => ['visibility' => EventVisibility::Private]);
|
||||
}
|
||||
|
||||
public function publicEvent(): static
|
||||
{
|
||||
return $this->state(fn () => ['visibility' => EventVisibility::Public]);
|
||||
return $this->state(fn () => ['status' => 'published']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\RsvpStatus;
|
||||
use App\Models\Event;
|
||||
use App\Models\EventInvitation;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<EventInvitation>
|
||||
*/
|
||||
final class EventInvitationFactory extends Factory
|
||||
{
|
||||
protected $model = EventInvitation::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'event_id' => Event::factory(),
|
||||
'user_id' => User::factory(),
|
||||
'rsvp_status' => RsvpStatus::Pending,
|
||||
'rsvp_note' => null,
|
||||
'rsvp_responded_at' => null,
|
||||
'invited_at' => now(),
|
||||
];
|
||||
}
|
||||
|
||||
public function pending(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'rsvp_status' => RsvpStatus::Pending,
|
||||
'rsvp_responded_at' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function available(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'rsvp_status' => RsvpStatus::Available,
|
||||
'rsvp_responded_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function unavailable(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'rsvp_status' => RsvpStatus::Unavailable,
|
||||
'rsvp_responded_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function tentative(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'rsvp_status' => RsvpStatus::Tentative,
|
||||
'rsvp_responded_at' => now(),
|
||||
'rsvp_note' => fake()->sentence(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Location;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Location>
|
||||
*/
|
||||
final class LocationFactory extends Factory
|
||||
{
|
||||
protected $model = Location::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->company() . ' ' . fake()->randomElement(['Theater', 'Hall', 'Arena', 'Club', 'Venue']),
|
||||
'address' => fake()->streetAddress(),
|
||||
'city' => fake()->city(),
|
||||
'postal_code' => fake()->postcode(),
|
||||
'country' => 'NL',
|
||||
'latitude' => fake()->optional()->latitude(),
|
||||
'longitude' => fake()->optional()->longitude(),
|
||||
'capacity' => fake()->optional()->numberBetween(50, 2000),
|
||||
'contact_name' => fake()->optional()->name(),
|
||||
'contact_email' => fake()->optional()->safeEmail(),
|
||||
'contact_phone' => fake()->optional()->phoneNumber(),
|
||||
'notes' => fake()->optional()->paragraph(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
25
api/database/factories/OrganisationFactory.php
Normal file
25
api/database/factories/OrganisationFactory.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Organisation;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/** @extends Factory<Organisation> */
|
||||
final class OrganisationFactory extends Factory
|
||||
{
|
||||
/** @return array<string, mixed> */
|
||||
public function definition(): array
|
||||
{
|
||||
$name = fake()->unique()->company();
|
||||
|
||||
return [
|
||||
'name' => $name,
|
||||
'slug' => str($name)->slug()->toString(),
|
||||
'billing_status' => 'active',
|
||||
'settings' => [],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
/** @extends Factory<User> */
|
||||
final class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
/** @return array<string, mixed> */
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
@@ -28,17 +22,14 @@ class UserFactory extends Factory
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'timezone' => 'Europe/Amsterdam',
|
||||
'locale' => 'nl',
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
return $this->state(fn () => ['email_verified_at' => null]);
|
||||
}
|
||||
}
|
||||
|
||||
30
api/database/factories/UserInvitationFactory.php
Normal file
30
api/database/factories/UserInvitationFactory.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Organisation;
|
||||
use App\Models\User;
|
||||
use App\Models\UserInvitation;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/** @extends Factory<UserInvitation> */
|
||||
final class UserInvitationFactory extends Factory
|
||||
{
|
||||
/** @return array<string, mixed> */
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'invited_by_user_id' => User::factory(),
|
||||
'organisation_id' => Organisation::factory(),
|
||||
'event_id' => null,
|
||||
'role' => 'org_member',
|
||||
'token' => strtolower((string) Str::ulid()),
|
||||
'status' => 'pending',
|
||||
'expires_at' => now()->addDays(7),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?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('customers', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->string('name');
|
||||
$table->string('company_name')->nullable();
|
||||
$table->enum('type', ['individual', 'company'])->default('individual');
|
||||
$table->string('email')->nullable();
|
||||
$table->string('phone', 20)->nullable();
|
||||
$table->text('address')->nullable();
|
||||
$table->string('city')->nullable();
|
||||
$table->string('postal_code', 20)->nullable();
|
||||
$table->string('country', 2)->default('NL');
|
||||
$table->text('notes')->nullable();
|
||||
$table->boolean('is_portal_enabled')->default(false);
|
||||
$table->foreignUlid('user_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['type', 'city']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('customers');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
<?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->string('name');
|
||||
$table->text('address')->nullable();
|
||||
$table->string('city');
|
||||
$table->string('postal_code', 20)->nullable();
|
||||
$table->string('country', 2)->default('NL');
|
||||
$table->decimal('latitude', 10, 7)->nullable();
|
||||
$table->decimal('longitude', 10, 7)->nullable();
|
||||
$table->unsignedInteger('capacity')->nullable();
|
||||
$table->string('contact_name')->nullable();
|
||||
$table->string('contact_email')->nullable();
|
||||
$table->string('contact_phone', 20)->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('city');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('locations');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<?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('setlists', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->string('name');
|
||||
$table->text('description')->nullable();
|
||||
$table->unsignedInteger('total_duration_seconds')->nullable();
|
||||
$table->boolean('is_template')->default(false);
|
||||
$table->boolean('is_archived')->default(false);
|
||||
$table->foreignUlid('created_by')->constrained('users');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['is_template', 'is_archived']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('setlists');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
<?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('events', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->string('title');
|
||||
$table->text('description')->nullable();
|
||||
$table->foreignUlid('location_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignUlid('customer_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignUlid('setlist_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->date('event_date');
|
||||
$table->time('start_time');
|
||||
$table->time('end_time')->nullable();
|
||||
$table->time('load_in_time')->nullable();
|
||||
$table->time('soundcheck_time')->nullable();
|
||||
$table->decimal('fee', 10, 2)->nullable();
|
||||
$table->string('currency', 3)->default('EUR');
|
||||
$table->enum('status', ['draft', 'pending', 'confirmed', 'completed', 'cancelled'])->default('draft');
|
||||
$table->enum('visibility', ['private', 'members', 'public'])->default('members');
|
||||
$table->dateTime('rsvp_deadline')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->text('internal_notes')->nullable();
|
||||
$table->boolean('is_public_setlist')->default(false);
|
||||
$table->foreignUlid('created_by')->constrained('users');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['event_date', 'status']);
|
||||
$table->index('status');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('events');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
<?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('event_invitations', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('event_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->enum('rsvp_status', ['pending', 'available', 'unavailable', 'tentative'])->default('pending');
|
||||
$table->text('rsvp_note')->nullable();
|
||||
$table->timestamp('rsvp_responded_at')->nullable();
|
||||
$table->timestamp('invited_at');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['event_id', 'user_id']);
|
||||
$table->index(['user_id', 'rsvp_status']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('event_invitations');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<?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('music_numbers', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->string('title');
|
||||
$table->string('artist')->nullable();
|
||||
$table->string('genre')->nullable();
|
||||
$table->unsignedInteger('duration_seconds')->nullable();
|
||||
$table->string('key', 10)->nullable();
|
||||
$table->unsignedSmallInteger('tempo_bpm')->nullable();
|
||||
$table->string('time_signature', 10)->nullable();
|
||||
$table->text('lyrics')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->json('tags')->nullable();
|
||||
$table->unsignedInteger('play_count')->default(0);
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->foreignUlid('created_by')->constrained('users');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['is_active', 'title']);
|
||||
$table->index('genre');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('music_numbers');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
<?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('music_attachments', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('music_number_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('file_name');
|
||||
$table->string('original_name');
|
||||
$table->string('file_path');
|
||||
$table->enum('file_type', ['lyrics', 'chords', 'sheet_music', 'audio', 'other'])->default('other');
|
||||
$table->unsignedInteger('file_size');
|
||||
$table->string('mime_type');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['music_number_id', 'file_type']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('music_attachments');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
<?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('setlist_items', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('setlist_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('music_number_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->unsignedSmallInteger('position');
|
||||
$table->unsignedTinyInteger('set_number')->default(1);
|
||||
$table->boolean('is_break')->default(false);
|
||||
$table->unsignedSmallInteger('break_duration_seconds')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['setlist_id', 'position']);
|
||||
$table->index(['setlist_id', 'set_number']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('setlist_items');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
<?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('booking_requests', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('customer_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->string('contact_name');
|
||||
$table->string('contact_email');
|
||||
$table->string('contact_phone', 20)->nullable();
|
||||
$table->string('event_type')->nullable();
|
||||
$table->date('preferred_date');
|
||||
$table->date('alternative_date')->nullable();
|
||||
$table->time('preferred_time')->nullable();
|
||||
$table->string('location')->nullable();
|
||||
$table->unsignedInteger('expected_guests')->nullable();
|
||||
$table->decimal('budget', 10, 2)->nullable();
|
||||
$table->text('message')->nullable();
|
||||
$table->enum('status', ['new', 'contacted', 'quoted', 'accepted', 'declined', 'cancelled'])->default('new');
|
||||
$table->text('internal_notes')->nullable();
|
||||
$table->foreignUlid('assigned_to')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->foreignUlid('converted_event_id')->nullable()->constrained('events')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['status', 'preferred_date']);
|
||||
$table->index('assigned_to');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('booking_requests');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
<?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('activity_logs', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->string('log_name')->nullable();
|
||||
$table->text('description');
|
||||
$table->nullableMorphs('subject');
|
||||
$table->nullableMorphs('causer');
|
||||
$table->json('properties')->nullable();
|
||||
$table->string('event')->nullable();
|
||||
$table->uuid('batch_uuid')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('log_name');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('activity_logs');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
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('activity_log', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('log_name')->nullable()->index();
|
||||
$table->text('description');
|
||||
$table->nullableMorphs('subject', 'subject');
|
||||
$table->string('event')->nullable();
|
||||
$table->nullableMorphs('causer', 'causer');
|
||||
$table->json('attribute_changes')->nullable();
|
||||
$table->json('properties')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$teams = config('permission.teams');
|
||||
$tableNames = config('permission.table_names');
|
||||
$columnNames = config('permission.column_names');
|
||||
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
|
||||
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
|
||||
|
||||
throw_if(empty($tableNames), 'Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
throw_if($teams && empty($columnNames['team_foreign_key'] ?? null), 'Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
|
||||
/**
|
||||
* See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered.
|
||||
*/
|
||||
Schema::create($tableNames['permissions'], static function (Blueprint $table) {
|
||||
$table->id(); // permission id
|
||||
$table->string('name');
|
||||
$table->string('guard_name');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['name', 'guard_name']);
|
||||
});
|
||||
|
||||
/**
|
||||
* See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered.
|
||||
*/
|
||||
Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) {
|
||||
$table->id(); // role id
|
||||
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
|
||||
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
|
||||
}
|
||||
$table->string('name');
|
||||
$table->string('guard_name');
|
||||
$table->timestamps();
|
||||
if ($teams || config('permission.testing')) {
|
||||
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
|
||||
} else {
|
||||
$table->unique(['name', 'guard_name']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->string($columnNames['model_morph_key'], 26);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->cascadeOnDelete();
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->string($columnNames['model_morph_key'], 26);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->cascadeOnDelete();
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->cascadeOnDelete();
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->cascadeOnDelete();
|
||||
|
||||
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
|
||||
});
|
||||
|
||||
app('cache')
|
||||
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
|
||||
->forget(config('permission.cache.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
|
||||
throw_if(empty($tableNames), 'Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||
|
||||
Schema::dropIfExists($tableNames['role_has_permissions']);
|
||||
Schema::dropIfExists($tableNames['model_has_roles']);
|
||||
Schema::dropIfExists($tableNames['model_has_permissions']);
|
||||
Schema::dropIfExists($tableNames['roles']);
|
||||
Schema::dropIfExists($tableNames['permissions']);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
<?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('users', function (Blueprint $table) {
|
||||
// Remove old band-management columns
|
||||
$table->dropIndex(['type', 'status']);
|
||||
$table->dropColumn(['phone', 'bio', 'instruments', 'avatar_path', 'type', 'role', 'status']);
|
||||
});
|
||||
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
// Add EventCrew columns per SCHEMA.md
|
||||
$table->string('timezone')->default('Europe/Amsterdam')->after('password');
|
||||
$table->string('locale')->default('nl')->after('timezone');
|
||||
$table->string('avatar')->nullable()->after('locale');
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropSoftDeletes();
|
||||
$table->dropColumn(['timezone', 'locale', 'avatar']);
|
||||
});
|
||||
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('phone', 20)->nullable();
|
||||
$table->text('bio')->nullable();
|
||||
$table->json('instruments')->nullable();
|
||||
$table->string('avatar_path')->nullable();
|
||||
$table->enum('type', ['member', 'customer'])->default('member');
|
||||
$table->enum('role', ['admin', 'booking_agent', 'music_manager', 'member'])->nullable();
|
||||
$table->enum('status', ['active', 'inactive'])->default('active');
|
||||
$table->index(['type', 'status']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -10,21 +10,19 @@ return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('notifications', function (Blueprint $table) {
|
||||
Schema::create('organisations', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->string('type');
|
||||
$table->morphs('notifiable');
|
||||
$table->json('data');
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->string('billing_status')->default('active');
|
||||
$table->json('settings')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['notifiable_type', 'notifiable_id', 'read_at']);
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('notifications');
|
||||
Schema::dropIfExists('organisations');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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::create('organisation_user', function (Blueprint $table) {
|
||||
$table->id(); // int AI for join performance
|
||||
$table->foreignUlid('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('organisation_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('role');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['user_id', 'organisation_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('organisation_user');
|
||||
}
|
||||
};
|
||||
@@ -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('events', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('organisation_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('slug');
|
||||
$table->date('start_date');
|
||||
$table->date('end_date');
|
||||
$table->string('timezone')->default('Europe/Amsterdam');
|
||||
$table->enum('status', [
|
||||
'draft',
|
||||
'published',
|
||||
'registration_open',
|
||||
'buildup',
|
||||
'showday',
|
||||
'teardown',
|
||||
'closed',
|
||||
])->default('draft');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['organisation_id', 'status']);
|
||||
$table->unique(['organisation_id', 'slug']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('events');
|
||||
}
|
||||
};
|
||||
@@ -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('user_invitations', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->string('email');
|
||||
$table->foreignUlid('invited_by_user_id')->constrained('users')->cascadeOnDelete();
|
||||
$table->foreignUlid('organisation_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('event_id')->nullable()->constrained()->cascadeOnDelete();
|
||||
$table->string('role');
|
||||
$table->ulid('token')->unique();
|
||||
$table->enum('status', ['pending', 'accepted', 'expired'])->default('pending');
|
||||
$table->timestamp('expires_at');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['email', 'status']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('user_invitations');
|
||||
}
|
||||
};
|
||||
@@ -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::create('event_user_roles', function (Blueprint $table) {
|
||||
$table->id(); // int AI for join performance
|
||||
$table->foreignUlid('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('event_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('role');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['user_id', 'event_id', 'role']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('event_user_roles');
|
||||
}
|
||||
};
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Organisation;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
@@ -12,44 +13,23 @@ class DatabaseSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
// Create admin user
|
||||
User::create([
|
||||
'name' => 'Admin User',
|
||||
'email' => 'admin@bandmanagement.nl',
|
||||
$this->call(RoleSeeder::class);
|
||||
|
||||
$admin = User::create([
|
||||
'name' => 'Super Admin',
|
||||
'email' => 'admin@eventcrew.nl',
|
||||
'password' => Hash::make('password'),
|
||||
'type' => 'member',
|
||||
'role' => 'admin',
|
||||
'status' => 'active',
|
||||
]);
|
||||
|
||||
// Create booking agent
|
||||
User::create([
|
||||
'name' => 'Booking Agent',
|
||||
'email' => 'booking@bandmanagement.nl',
|
||||
'password' => Hash::make('password'),
|
||||
'type' => 'member',
|
||||
'role' => 'booking_agent',
|
||||
'status' => 'active',
|
||||
$admin->assignRole('super_admin');
|
||||
|
||||
$organisation = Organisation::query()->create([
|
||||
'name' => 'Demo Organisation',
|
||||
'slug' => 'demo',
|
||||
'billing_status' => 'active',
|
||||
'settings' => [],
|
||||
]);
|
||||
|
||||
// Create music manager
|
||||
User::create([
|
||||
'name' => 'Music Manager',
|
||||
'email' => 'music@bandmanagement.nl',
|
||||
'password' => Hash::make('password'),
|
||||
'type' => 'member',
|
||||
'role' => 'music_manager',
|
||||
'status' => 'active',
|
||||
]);
|
||||
|
||||
// Create regular member
|
||||
User::create([
|
||||
'name' => 'Band Member',
|
||||
'email' => 'member@bandmanagement.nl',
|
||||
'password' => Hash::make('password'),
|
||||
'type' => 'member',
|
||||
'role' => 'member',
|
||||
'status' => 'active',
|
||||
]);
|
||||
$admin->organisations()->attach($organisation->id, ['role' => 'org_admin']);
|
||||
}
|
||||
}
|
||||
|
||||
26
api/database/seeders/RoleSeeder.php
Normal file
26
api/database/seeders/RoleSeeder.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class RoleSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
// App-level
|
||||
Role::findOrCreate('super_admin', 'web');
|
||||
|
||||
// Organisation-level
|
||||
Role::findOrCreate('org_admin', 'web');
|
||||
Role::findOrCreate('org_member', 'web');
|
||||
|
||||
// Event-level
|
||||
Role::findOrCreate('event_manager', 'web');
|
||||
Role::findOrCreate('staff_coordinator', 'web');
|
||||
Role::findOrCreate('volunteer_coordinator', 'web');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user