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(); + }); + } +};