From 4c3aa87acf45e3ed4939eaf66eb48e84a4a22c9f Mon Sep 17 00:00:00 2001 From: joddyabott Date: Wed, 1 Oct 2025 10:23:01 +0330 Subject: [PATCH] create one column for radaran and add in rahdaran controller --- .../Controllers/V3/RahdaranController.php | 5 ++++ ...0511_add_edareh_name_to_rahdaran_table.php | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 database/migrations/2025_10_01_100511_add_edareh_name_to_rahdaran_table.php diff --git a/app/Http/Controllers/V3/RahdaranController.php b/app/Http/Controllers/V3/RahdaranController.php index a4128cc3..04591522 100644 --- a/app/Http/Controllers/V3/RahdaranController.php +++ b/app/Http/Controllers/V3/RahdaranController.php @@ -7,6 +7,7 @@ use App\Http\Controllers\Controller; use App\Http\Requests\V3\Rahdaran\StoreRequest; use App\Http\Requests\V3\Rahdaran\UpdateRequest; use App\Http\Traits\ApiResponse; +use App\Models\EdarateShahri; use App\Models\Province; use App\Models\Rahdaran; use Illuminate\Database\QueryException; @@ -30,6 +31,7 @@ class RahdaranController extends Controller public function store(StoreRequest $request): JsonResponse { $province = Province::query()->find($request->input('province_id')); + $edareh = EdarateShahri::query()->find($request->input('edareh_shahri_id')); Rahdaran::query()->create([ 'name' => $request->name, @@ -38,6 +40,7 @@ class RahdaranController extends Controller 'province_id' => $province->id, 'province_name' => $province->name_fa, 'edareh_shahri_id' => $request->edareh_shahri_id, + 'edareh_shahri_name' => $edareh->name_fa, ]); return $this->successResponse(); @@ -51,6 +54,7 @@ class RahdaranController extends Controller public function update(UpdateRequest $request, Rahdaran $rahdaran): JsonResponse { $province = Province::query()->find($request->input('province_id')); + $edareh = EdarateShahri::query()->find($request->input('edareh_shahri_id')); $rahdaran->update([ 'name' =>$request->name, @@ -59,6 +63,7 @@ class RahdaranController extends Controller 'province_id' => $province->id, 'province_name' => $province->name_fa, 'edareh_shahri_id' => $request->edareh_shahri_id, + 'edareh_shahri_name' => $edareh->name_fa, ]); return $this->successResponse(); diff --git a/database/migrations/2025_10_01_100511_add_edareh_name_to_rahdaran_table.php b/database/migrations/2025_10_01_100511_add_edareh_name_to_rahdaran_table.php new file mode 100644 index 00000000..bc16552f --- /dev/null +++ b/database/migrations/2025_10_01_100511_add_edareh_name_to_rahdaran_table.php @@ -0,0 +1,28 @@ +string('edareh_shahri_name')->nullable()->after('edareh_shahri_id'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('rahdaran', function (Blueprint $table) { + $table->dropColumn('edareh_shahri_name'); + }); + } +};