create one column for radaran and add in rahdaran controller
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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('rahdaran', function (Blueprint $table) {
|
||||
$table->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');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user