From d140e38920b6a8686f3a31676b837a09fdf58b6c Mon Sep 17 00:00:00 2001 From: Leon Date: Fri, 19 Dec 2025 12:19:18 +0100 Subject: [PATCH] feat: partner id nullable --- app/Http/Controllers/HuntsController.php | 5 ++-- ...ake_partner_id_nullable_in_hunts_table.php | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2025_12_19_111126_make_partner_id_nullable_in_hunts_table.php diff --git a/app/Http/Controllers/HuntsController.php b/app/Http/Controllers/HuntsController.php index ab5a7ca..f11aab7 100644 --- a/app/Http/Controllers/HuntsController.php +++ b/app/Http/Controllers/HuntsController.php @@ -31,7 +31,7 @@ class HuntsController extends Controller public function store(Request $request) { $validated = $request->validate([ - 'partner_id' => 'required|string', + 'partner_id' => 'nullable|string', 'title' => 'required|string', 'slug' => 'required|string|unique:hunts,slug', 'description' => 'nullable|string', @@ -45,9 +45,10 @@ class HuntsController extends Controller 'start_at' => 'nullable|date', 'end_at' => 'nullable|date', 'image' => 'nullable|string', - 'creator_id' => 'nullable|exists:users,id', ]); + $validated['creator_id'] = auth()->id(); + $hunt = Hunts::create($validated); return response()->json($hunt, 201); diff --git a/database/migrations/2025_12_19_111126_make_partner_id_nullable_in_hunts_table.php b/database/migrations/2025_12_19_111126_make_partner_id_nullable_in_hunts_table.php new file mode 100644 index 0000000..b2a694a --- /dev/null +++ b/database/migrations/2025_12_19_111126_make_partner_id_nullable_in_hunts_table.php @@ -0,0 +1,28 @@ +string('partner_id')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('hunts', function (Blueprint $table) { + $table->string('partner_id')->nullable(false)->change(); + }); + } +};