create controller and these dependensi
This commit is contained in:
@@ -8,7 +8,7 @@ enum HarimStates: int
|
||||
case Baresi_Imeni_Rah_Tavasot_Daftar_Harim = 2;
|
||||
case Baresi_Imeni_Rah_Tavasot_Moaven = 3;
|
||||
case Baresi_Imeni_Rah_Tavasot_Modir_Kol = 4;
|
||||
case Rad_Be_Dalil_Imeni_Rah = 5;
|
||||
case ERSAL_BE_PANJAREVAHED = 5;
|
||||
|
||||
public static function name(int $state): string
|
||||
{
|
||||
@@ -17,7 +17,7 @@ enum HarimStates: int
|
||||
2 => "بررسی ایمنی راه توسط ادارات حریم",
|
||||
3 => "بررسی ایمنی راه توسط معاون ",
|
||||
4 => "بررسی ایمنی راه توسط مدیر کل",
|
||||
5 => "رد درخواست به دلیل ایمنی راه",
|
||||
5 => "ارسال به پنجره واحد",
|
||||
];
|
||||
|
||||
return $mapArray[$state];
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Harim;
|
||||
|
||||
use App\Enums\HarimAction;
|
||||
use App\Enums\HarimStates;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\GeneralManager\ConfirmRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\GeneralManager\RejectRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\Harim;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class GeneralManagerController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
$query = Harim::query()
|
||||
->where('state_id','=',HarimStates::Baresi_Imeni_Rah_Tavasot_Modir_Kol->value)
|
||||
->where('edare_shahri_id', '=', $user->edarate_shahri_id)
|
||||
->with('histories:expert_description');
|
||||
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*']
|
||||
);
|
||||
return response()->json($data);
|
||||
}
|
||||
public function conform(ConfirmRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request, $harim) {
|
||||
$action = HarimAction::CONFIRM->value;
|
||||
$harim->histories()->create([
|
||||
'user_id' => auth()->user()->id,
|
||||
'previous_state_id' => $harim->state_id,
|
||||
'previous_state_name' => $harim->state_name,
|
||||
'expert_description' => $request->expert_description,
|
||||
'action_id' => $action,
|
||||
'action_name' => HarimAction::name($action),
|
||||
]);
|
||||
|
||||
$state = HarimStates::ERSAL_BE_PANJAREVAHED->value;
|
||||
$harim->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function reject(RejectRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request, $harim) {
|
||||
$action = HarimAction::REJECT->value;
|
||||
$harim->histories()->create([
|
||||
'user_id'=> auth()->user()->id,
|
||||
'previous-state_id' => $harim->state_id,
|
||||
'previous_state_name' => $harim->state_name,
|
||||
'export_description' => $request->export_description,
|
||||
'action_id' => $action,
|
||||
'action_name' => HarimAction::name($action),
|
||||
]);
|
||||
$state = HarimStates::Baresi_Imeni_Rah_Tavasot_Moaven->value;
|
||||
$harim->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
}
|
||||
public function show(Harim $harim): JsonResponse
|
||||
{
|
||||
return $this->successResponse($harim);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,11 @@ class HarimOfficeController extends Controller
|
||||
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$query = Harim::query()->where('edareh_shahri_id', '=', auth()->user()->edarate_shahri_id);
|
||||
$user = auth()->user();
|
||||
$query = Harim::query()
|
||||
->where('state_id','=',HarimStates::Baresi_Imeni_Rah_Tavasot_Daftar_Harim->value)
|
||||
->where('edare_shahri_id', '=', $user->edarate_shahri_id)
|
||||
->with('expert_description');
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
@@ -47,6 +51,7 @@ class HarimOfficeController extends Controller
|
||||
$harim ->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
'final_description' => 'yes'
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
@@ -69,6 +74,7 @@ class HarimOfficeController extends Controller
|
||||
$harim ->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
'final_description' => 'no'
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
|
||||
@@ -20,7 +20,10 @@ class ProvinceOfficeController extends Controller
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
$query = Harim::query()->where('edareh_shahri_id', '=', $user->edarate_shahri_id);
|
||||
$query = Harim::query()
|
||||
->where('state_id','=',HarimStates::Baresi_Edare_Shahrestan->value)
|
||||
->where('edare_shahri_id', '=', $user->edarate_shahri_id);
|
||||
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
@@ -33,13 +36,15 @@ class ProvinceOfficeController extends Controller
|
||||
public function feedback(FeedBackRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request,$harim) {
|
||||
$action = HarimAction::FEEDBACK->value;
|
||||
|
||||
$harim->histories()->create([
|
||||
'user_id' => auth()->user()->id,
|
||||
'previous_state_id' => $harim->state_id,
|
||||
'previous_state_name' => $harim->state_name,
|
||||
'expert_description' => $request->expert_description,
|
||||
'action_id' => HarimAction::FEEDBACK->value,
|
||||
'action_name' => HarimAction::FEEDBACK->name,
|
||||
'action_id' => $action,
|
||||
'action_name' => HarimAction::name($action),
|
||||
]);
|
||||
|
||||
$state = HarimStates::Baresi_Imeni_Rah_Tavasot_Daftar_Harim->value;
|
||||
@@ -55,6 +60,5 @@ class ProvinceOfficeController extends Controller
|
||||
public function show(Harim $harim): JsonResponse
|
||||
{
|
||||
return $this->successResponse($harim);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Harim;
|
||||
|
||||
use App\Enums\HarimAction;
|
||||
use App\Enums\HarimStates;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\Deputy\ConfirmRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\Harim;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class TechnicalDeputyController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
$query = Harim::query()
|
||||
->where('state_id', '=', HarimStates::Baresi_Imeni_Rah_Tavasot_Moaven->value)
|
||||
->where('edare_shahri_id', '=', $user->edarate_shahri_id)
|
||||
->with('histories:expert_description');
|
||||
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
);
|
||||
return response()->json($data);
|
||||
}
|
||||
public function conform(ConfirmRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request,$harim) {
|
||||
$action = HarimAction::CONFIRM->value;
|
||||
|
||||
$harim->histories()->create([
|
||||
'user_id' => auth()->user()->id,
|
||||
'previous_state_id' => $harim->state_id,
|
||||
'previous_state_name' => $harim->state_name,
|
||||
'expert_description' => $request->expert_description,
|
||||
'action_id' => $action,
|
||||
'action_name' => HarimAction::name($action),
|
||||
]);
|
||||
$state = HarimStates::Baresi_Imeni_Rah_Tavasot_Modir_Kol->value;
|
||||
|
||||
$harim ->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
|
||||
}
|
||||
public function reject(ConfirmRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
DB::transaction(function () use ($request,$harim) {
|
||||
$action = HarimAction::REJECT->value;
|
||||
|
||||
$harim->histories()->create([
|
||||
'user_id' => auth()->user()->id,
|
||||
'previous_state_id' => $harim->state_id,
|
||||
'previous_state_name' => $harim->state_name,
|
||||
'expert_description' => $request->expert_description,
|
||||
'action_id' => $action,
|
||||
'action_name' => HarimAction::name($action),
|
||||
]);
|
||||
$state = HarimStates::Baresi_Imeni_Rah_Tavasot_Daftar_Harim->value;
|
||||
$harim->update([
|
||||
'state_id' => $state,
|
||||
'state_name' => HarimStates::name($state),
|
||||
]);
|
||||
});
|
||||
return $this->successResponse();
|
||||
}
|
||||
public function show(Harim $harim): JsonResponse
|
||||
{
|
||||
return $this->successResponse($harim);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\Deputy;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ConfirmRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->harim->edare_shahri_id == auth()->user()->edarate_shahri_id &&
|
||||
$this->harim->state_id == HarimStates::Baresi_Imeni_Rah_Tavasot_Moaven->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 [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\Deputy;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RejectRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->harim->edare_shahri_id == auth()->user()->edarate_shahri_id &&
|
||||
$this->harim->state_id == HarimStates::Baresi_Imeni_Rah_Tavasot_Moaven->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 [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\GeneralManager;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ConfirmRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->harim->edare_shahri_id == auth()->user()->edarate_shahri_id &&
|
||||
$this->harim->state_id == HarimStates::Baresi_Imeni_Rah_Tavasot_Modir_Kol->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 [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\GeneralManager;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RejectRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->harim->edare_shahri_id == auth()->user()->edarate_shahri_id &&
|
||||
$this->harim->state_id == HarimStates::Baresi_Imeni_Rah_Tavasot_Modir_Kol->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 [
|
||||
'expert_description' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,8 @@ class NoRequest extends FormRequest
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->harim->edare_shahri_id == auth()->user()->edarate_shahri_id &&
|
||||
$this->harim->state_id == HarimStates::Baresi_Imeni_Rah_Tavasot_Daftar_Harim->value; }
|
||||
$this->harim->state_id == HarimStates::Baresi_Imeni_Rah_Tavasot_Daftar_Harim->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshSampleController;
|
||||
use App\Http\Controllers\V3\Dashboard\Azmayesh\AzmayeshTypeController;
|
||||
use App\Http\Controllers\V3\Dashboard\Harim\HarimOfficeController;
|
||||
use App\Http\Controllers\V3\Dashboard\Harim\ProvinceOfficeController;
|
||||
use App\Http\Controllers\V3\Dashboard\Harim\TechnicalDeputyController;
|
||||
use App\Http\Controllers\V3\Dashboard\ItemsManagementController;
|
||||
use App\Http\Controllers\V3\Dashboard\Mission\ControlUnitController;
|
||||
use App\Http\Controllers\V3\Dashboard\Mission\DetailController;
|
||||
@@ -528,5 +529,14 @@ Route::prefix('harim')
|
||||
Route::post('/no/{harim}', 'no')->name('no');
|
||||
Route::get('/{harim}', 'show')->name('show');
|
||||
});
|
||||
Route::prefix('technical_deputy')
|
||||
->name('technical_deputy.')
|
||||
->controller(TechnicalDeputyController::class)
|
||||
->group(function () {
|
||||
Route::get('/', 'index')->name('index');
|
||||
Route::post('/conform/{harim}', 'conform')->name('conform');
|
||||
Route::post('/reject/{harim}', 'reject')->name('reject');
|
||||
Route::get('/{harim}', 'show')->name('show');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user