From 9a162d6d1a5fab91855c1a6d180f65cb90c41450 Mon Sep 17 00:00:00 2001 From: Samuel De Backer Date: Fri, 27 May 2022 10:39:15 +0200 Subject: [PATCH] nullOnDelete() method --- database/migrations/create_events_table.php.stub | 2 +- database/migrations/create_registrations_table.php.stub | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/database/migrations/create_events_table.php.stub b/database/migrations/create_events_table.php.stub index 8aaa85d..416dd6d 100644 --- a/database/migrations/create_events_table.php.stub +++ b/database/migrations/create_events_table.php.stub @@ -17,7 +17,7 @@ class CreateEventsTable extends Migration $table->date('start_date'); $table->date('end_date'); $table->boolean('registration_form'); - $table->foreignId('image_id')->nullable(); + $table->foreignId('image_id')->nullable()->constrained('files')->nullOnDelete(); $table->json('status')->default(new Expression('(JSON_OBJECT())')); $table->json('title')->default(new Expression('(JSON_OBJECT())')); $table->json('slug')->default(new Expression('(JSON_OBJECT())')); diff --git a/database/migrations/create_registrations_table.php.stub b/database/migrations/create_registrations_table.php.stub index 59ed7ec..758731f 100644 --- a/database/migrations/create_registrations_table.php.stub +++ b/database/migrations/create_registrations_table.php.stub @@ -14,7 +14,7 @@ class CreateRegistrationsTable extends Migration Schema::create('registrations', function (Blueprint $table) { $table->id(); $table->foreignId('event_id')->constrained(); - $table->foreignId('user_id')->nullable(); + $table->foreignId('user_id')->nullable()->constrained()->nullOnDelete(); $table->unsignedInteger('number_of_people'); $table->string('email')->nullable(); $table->string('first_name')->nullable();