fix: make user id nullable
This commit is contained in:
@@ -120,7 +120,7 @@ public function packageStore(Request $request, PackageName $packageName)
|
|||||||
$reminder = Reminder::create([
|
$reminder = Reminder::create([
|
||||||
...$data,
|
...$data,
|
||||||
'package_name_id' => $packageName->id,
|
'package_name_id' => $packageName->id,
|
||||||
'user_id' => Auth::id()
|
'user_id' => null
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return response()->json($reminder, 201);
|
return response()->json($reminder, 201);
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
Schema::table('reminders', function (Blueprint $table) {
|
||||||
|
// First, drop the foreign key constraint
|
||||||
|
$table->dropForeign(['user_id']);
|
||||||
|
|
||||||
|
// Make the column nullable
|
||||||
|
$table->foreignId('user_id')->nullable()->change();
|
||||||
|
|
||||||
|
// Re-add the foreign key constraint with nullable
|
||||||
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('CASCADE');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('reminders', function (Blueprint $table) {
|
||||||
|
$table->dropForeign(['user_id']);
|
||||||
|
$table->foreignId('user_id')->change();
|
||||||
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('CASCADE');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user