create new controller and fix the other

This commit is contained in:
2025-08-06 10:05:20 +03:30
parent 0e8b8fda7e
commit 43ad404635
6 changed files with 52 additions and 5 deletions

View File

@@ -7,6 +7,7 @@ use App\Enums\HarimStates;
use App\Facades\DataTable\DataTableFacade;
use App\Http\Controllers\Controller;
use App\Http\Requests\V3\Dashboard\Harim\ProvinceOffice\FeedBackRequest;
use App\Http\Requests\V3\Dashboard\Harim\ProvinceOffice\ShowRequest;
use App\Http\Traits\ApiResponse;
use App\Models\Harim;
use Illuminate\Http\JsonResponse;
@@ -56,4 +57,9 @@ class ProvinceOfficeController extends Controller
});
return $this->successResponse();
}
public function show(ShowRequest $request, Harim $harim): JsonResponse
{
return $this->successResponse($harim);
}
}

View File

@@ -27,7 +27,7 @@ class TechnicalDeputyController extends Controller
HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_MOAVEN->value,
HarimStates::BARESI_TAVASOT_MOAVEN->value,
])
->where('edare_shahri_id', '=', auth()->user()->edarate_shahri_id);
->where('edareh_shahri_id', '=', auth()->user()->edarate_shahri_id);
$data = DataTableFacade::run(
$query,

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests\V3\Dashboard\Harim\ProvinceOffice;
use App\Enums\HarimStates;
use Illuminate\Foundation\Http\FormRequest;
class ShowRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return $this->harim->edareh_shahri_id == auth()->user()->edarate_shahri_id &&
$this->harim->state_id == HarimStates::BARESI_EDARE_SHAHRESTAN->value;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
//
];
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -14,4 +15,12 @@ class Harim extends Model
public function histories(): HasMany
{
return $this->hasMany(HarimHistory::class);
}}
}
protected function polygon(): Attribute
{
return Attribute::make(
get: fn($value) => json_decode($value)
);
}
}

View File

@@ -21,7 +21,7 @@ class HarimFactory extends Factory
public function definition(): array
{
return [
'state_id' => $this->faker->numberBetween(1,5),
'state_id' => $this->faker->numberBetween(1,15),
'state_name' => function (array $attributes) {
return HarimState::query()->find($attributes['state_id'])->name;
},
@@ -32,11 +32,11 @@ class HarimFactory extends Factory
'request_date' => $this->faker->date(),
'province_id' => Province::factory(),
'province_name' => function (array $attributes) {
return Province::query()->find($attributes['province_id'])->name;
return Province::query()->find($attributes['province_id'])->name_fa;
},
'city_id' => City::factory(),
'city_name' => function (array $attributes) {
return City::query()->find($attributes['city_id'])->name;
return City::query()->find($attributes['city_id'])->name_fa;
},
'edareh_shahri_id' => EdarateShahri::factory(),
'county' => $this->faker->citySuffix,

View File

@@ -518,6 +518,7 @@ Route::prefix('harim')
->group(function () {
Route::get('/', 'index')->name('index');
Route::post('/feedback/{harim}', 'feedback')->name('feedback');
Route::get('/{harim}', 'show')->name('show');
});
Route::prefix('harim_office')
->name('harim_office.')