create new controller and fix the other
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Enums\HarimStates;
|
|||||||
use App\Facades\DataTable\DataTableFacade;
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\V3\Dashboard\Harim\ProvinceOffice\FeedBackRequest;
|
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\Http\Traits\ApiResponse;
|
||||||
use App\Models\Harim;
|
use App\Models\Harim;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
@@ -56,4 +57,9 @@ class ProvinceOfficeController extends Controller
|
|||||||
});
|
});
|
||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function show(ShowRequest $request, Harim $harim): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse($harim);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class TechnicalDeputyController extends Controller
|
|||||||
HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_MOAVEN->value,
|
HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_MOAVEN->value,
|
||||||
HarimStates::BARESI_TAVASOT_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(
|
$data = DataTableFacade::run(
|
||||||
$query,
|
$query,
|
||||||
|
|||||||
@@ -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 [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
@@ -14,4 +15,12 @@ class Harim extends Model
|
|||||||
public function histories(): HasMany
|
public function histories(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(HarimHistory::class);
|
return $this->hasMany(HarimHistory::class);
|
||||||
}}
|
}
|
||||||
|
|
||||||
|
protected function polygon(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: fn($value) => json_decode($value)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class HarimFactory extends Factory
|
|||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'state_id' => $this->faker->numberBetween(1,5),
|
'state_id' => $this->faker->numberBetween(1,15),
|
||||||
'state_name' => function (array $attributes) {
|
'state_name' => function (array $attributes) {
|
||||||
return HarimState::query()->find($attributes['state_id'])->name;
|
return HarimState::query()->find($attributes['state_id'])->name;
|
||||||
},
|
},
|
||||||
@@ -32,11 +32,11 @@ class HarimFactory extends Factory
|
|||||||
'request_date' => $this->faker->date(),
|
'request_date' => $this->faker->date(),
|
||||||
'province_id' => Province::factory(),
|
'province_id' => Province::factory(),
|
||||||
'province_name' => function (array $attributes) {
|
'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_id' => City::factory(),
|
||||||
'city_name' => function (array $attributes) {
|
'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(),
|
'edareh_shahri_id' => EdarateShahri::factory(),
|
||||||
'county' => $this->faker->citySuffix,
|
'county' => $this->faker->citySuffix,
|
||||||
|
|||||||
@@ -518,6 +518,7 @@ Route::prefix('harim')
|
|||||||
->group(function () {
|
->group(function () {
|
||||||
Route::get('/', 'index')->name('index');
|
Route::get('/', 'index')->name('index');
|
||||||
Route::post('/feedback/{harim}', 'feedback')->name('feedback');
|
Route::post('/feedback/{harim}', 'feedback')->name('feedback');
|
||||||
|
Route::get('/{harim}', 'show')->name('show');
|
||||||
});
|
});
|
||||||
Route::prefix('harim_office')
|
Route::prefix('harim_office')
|
||||||
->name('harim_office.')
|
->name('harim_office.')
|
||||||
|
|||||||
Reference in New Issue
Block a user