diff --git a/app/Http/Controllers/MasterData/LandController.php b/app/Http/Controllers/MasterData/LandController.php index ccb8e2d..1030e7f 100644 --- a/app/Http/Controllers/MasterData/LandController.php +++ b/app/Http/Controllers/MasterData/LandController.php @@ -85,6 +85,7 @@ public function store(Request $request) DB::beginTransaction(); try { $land = new Land(); + $land->user_id = Auth::user()->id; $land->owner = $request->owner; $land->province_code = $request->province_id; $land->regency_code = $request->regency_id; @@ -185,6 +186,7 @@ public function update(Request $request, $id) DB::beginTransaction(); try { $land = Land::findOrFail($id); + $land->user_id = Auth::user()->id; $land->owner = $request->owner; $land->province_code = $request->province_id; $land->regency_code = $request->regency_id; diff --git a/database/migrations/2025_01_28_065420_create_land_table.php b/database/migrations/2025_01_28_065420_create_land_table.php index b287d21..abfee23 100644 --- a/database/migrations/2025_01_28_065420_create_land_table.php +++ b/database/migrations/2025_01_28_065420_create_land_table.php @@ -13,6 +13,7 @@ public function up(): void { Schema::create('land', function (Blueprint $table) { $table->id(); + $table->unsignedBigInteger('user_id'); $table->string('owner'); $table->string('province_code'); $table->string('regency_code'); @@ -22,6 +23,10 @@ public function up(): void $table->string('longitude'); $table->timestamps(); }); + + Schema::table('land', function (Blueprint $table) { + $table->foreign('user_id')->references('id')->on('users'); + }); } /**