Skip to content

Commit 9a162d6

Browse files
committed
nullOnDelete() method
1 parent 912d6cd commit 9a162d6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

database/migrations/create_events_table.php.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CreateEventsTable extends Migration
1717
$table->date('start_date');
1818
$table->date('end_date');
1919
$table->boolean('registration_form');
20-
$table->foreignId('image_id')->nullable();
20+
$table->foreignId('image_id')->nullable()->constrained('files')->nullOnDelete();
2121
$table->json('status')->default(new Expression('(JSON_OBJECT())'));
2222
$table->json('title')->default(new Expression('(JSON_OBJECT())'));
2323
$table->json('slug')->default(new Expression('(JSON_OBJECT())'));

database/migrations/create_registrations_table.php.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class CreateRegistrationsTable extends Migration
1414
Schema::create('registrations', function (Blueprint $table) {
1515
$table->id();
1616
$table->foreignId('event_id')->constrained();
17-
$table->foreignId('user_id')->nullable();
17+
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
1818
$table->unsignedInteger('number_of_people');
1919
$table->string('email')->nullable();
2020
$table->string('first_name')->nullable();

0 commit comments

Comments
 (0)