add contract_subitem_id to azmayeshes table

This commit is contained in:
2024-12-25 13:03:09 +03:30
parent 6d9848cbc9
commit 91b93e4575
4 changed files with 36 additions and 2 deletions

View File

@@ -36,7 +36,8 @@ class AzmayeshController extends Controller
'project_name',
'updated_at',
'created_at',
'user_name'
'user_name',
'contract_subitem_id'
);
$allowedFilters = $columns;
@@ -80,6 +81,7 @@ class AzmayeshController extends Controller
'province_name' => $province->name_fa,
'user_id' => $user->id,
'user_name' => $user->name,
'contract_subitem_id' => $request->contract_subitem_id
]);
return $this->successResponse();
@@ -117,6 +119,7 @@ class AzmayeshController extends Controller
'applicant' => $request->applicant ?? '-',
'province_id' => $province->id,
'province_name' => $province->name_fa,
'contract_subitem_id' => $request->contract_subitem_id
]);
return $this->successResponse();
@@ -133,7 +136,7 @@ class AzmayeshController extends Controller
return $this->successResponse();
}
catch (QueryException $exception) {
return $this->errorResponse('can not be deleted');
return $this->errorResponse('امکان حذف وجود ندارد');
}
}
}

View File

@@ -35,6 +35,7 @@ class StoreRequest extends FormRequest
'consultant' => 'string',
'applicant' => 'string',
'province_id' => 'required|exists:provinces,id',
'contract_subitem_id' => 'required|exists:contract_subitems,id',
];
}
}

View File

@@ -35,6 +35,7 @@ class UpdateRequest extends FormRequest
'consultant' => 'string',
'applicant' => 'string',
'province_id' => 'required|exists:provinces,id',
'contract_subitem_id' => 'required|exists:contract_subitems,id',
];
}
}

View File

@@ -0,0 +1,29 @@
<?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('azmayeshes', function (Blueprint $table) {
$table->foreignId('contract_subitem_id')->constrained('contract_subitems')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('azmayeshes', function (Blueprint $table) {
$table->dropForeign('contract_subitem_id');
$table->dropColumn(['contract_subitem_id']);
});
}
};