Merge pull request #24 from arieeefajar/fix/master-land

fix(master-land): add field user id
This commit is contained in:
Arie Fajar Bachtiar 2025-03-13 15:42:28 +07:00 committed by GitHub
commit d0a7871112
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -85,6 +85,7 @@ public function store(Request $request)
DB::beginTransaction(); DB::beginTransaction();
try { try {
$land = new Land(); $land = new Land();
$land->user_id = Auth::user()->id;
$land->owner = $request->owner; $land->owner = $request->owner;
$land->province_code = $request->province_id; $land->province_code = $request->province_id;
$land->regency_code = $request->regency_id; $land->regency_code = $request->regency_id;
@ -185,6 +186,7 @@ public function update(Request $request, $id)
DB::beginTransaction(); DB::beginTransaction();
try { try {
$land = Land::findOrFail($id); $land = Land::findOrFail($id);
$land->user_id = Auth::user()->id;
$land->owner = $request->owner; $land->owner = $request->owner;
$land->province_code = $request->province_id; $land->province_code = $request->province_id;
$land->regency_code = $request->regency_id; $land->regency_code = $request->regency_id;

View File

@ -13,6 +13,7 @@ public function up(): void
{ {
Schema::create('land', function (Blueprint $table) { Schema::create('land', function (Blueprint $table) {
$table->id(); $table->id();
$table->unsignedBigInteger('user_id');
$table->string('owner'); $table->string('owner');
$table->string('province_code'); $table->string('province_code');
$table->string('regency_code'); $table->string('regency_code');
@ -22,6 +23,10 @@ public function up(): void
$table->string('longitude'); $table->string('longitude');
$table->timestamps(); $table->timestamps();
}); });
Schema::table('land', function (Blueprint $table) {
$table->foreign('user_id')->references('id')->on('users');
});
} }
/** /**