fix code for routs and service
This commit is contained in:
@@ -9,10 +9,11 @@ class VerifyBySupervisorRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::allows('gate-supervise-road-observed');
|
||||
return Gate::allows('gate-supervise-road-observed',$this->roadObserved);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,12 +24,12 @@ class RoadObservationTableService
|
||||
];
|
||||
|
||||
|
||||
if ($user->hasPermissionTo('supervise-fast-react')) {
|
||||
if ($user->hasPermissionTo('show-fast-react')) {
|
||||
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
||||
->whereNotNull('road_observeds.status')
|
||||
->select($fields);
|
||||
}
|
||||
elseif ($user->hasPermissionTo('supervise-fast-react-province'))
|
||||
elseif ($user->hasPermissionTo('show-fast-react-province'))
|
||||
{
|
||||
if (is_null($user->province_id))
|
||||
{
|
||||
@@ -53,6 +53,10 @@ class RoadObservationTableService
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if (is_null($user->edarate_shahri_id)) {
|
||||
return $this->errorResponse('ادارهای برای شما در سامانه ثبت نشده است!');
|
||||
}
|
||||
|
||||
$fields = [
|
||||
'fk_RegisteredEventMessage', 'road_observeds.id', 'Title', 'road_observeds.created_at',
|
||||
'lat', 'lng', 'FeatureTypeTitle', 'Description', 'MobileForSendEventSms',
|
||||
@@ -66,20 +70,9 @@ class RoadObservationTableService
|
||||
->whereNotNull('road_observeds.province_id')
|
||||
->whereNotNull('status')
|
||||
->leftJoin('edarate_shahri', 'road_observeds.edarate_shahri_id', '=', 'edarate_shahri.id')
|
||||
->where('edarate_shahri_id', $user->edarate_shahri_id)
|
||||
->select($fields);
|
||||
|
||||
if ($user->hasPermissionTo('show-fast-react-province')) {
|
||||
if (is_null($user->province_id)) {
|
||||
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
|
||||
}
|
||||
$query->where('rms_province_id', $user->province_id);
|
||||
} elseif ($user->hasPermissionTo('show-fast-react-edarate-shahri')) {
|
||||
if (is_null($user->edarate_shahri_id)) {
|
||||
return $this->errorResponse('ادارهای برای شما در سامانه ثبت نشده است!');
|
||||
}
|
||||
$query->where('edarate_shahri_id', $user->edarate_shahri_id);
|
||||
}
|
||||
|
||||
return DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
|
||||
@@ -281,25 +281,29 @@ Route::prefix('road_observations')
|
||||
->name('roadObservations.')
|
||||
->controller(RoadObservationController::class)
|
||||
->group(function () {
|
||||
Route::get('/supervisor_index', 'supervisorIndex')->name('supervisorIndex')->middleware('permission:supervise-fast-react-province|supervise-fast-react');
|
||||
Route::get('/supervisor_index', 'supervisorIndex')->name('supervisorIndex')->middleware('permission:show-fast-react-province|show-fast-react');
|
||||
Route::post('/verify/{road_observed}', 'verifyBySupervisor')->name('verifyBySupervisor');
|
||||
Route::get('/supervisor_report', 'supervisorCartableReport')->name('supervisorCartableReport');
|
||||
Route::get('/operator_index','operatorIndex')->name('operatorIndex')->middleware('permission:show-fast-react|show-fast-react-province');
|
||||
Route::get('/operator_report','operatorCartableReport')->name('operatorCartableReport');
|
||||
Route::get('/supervisor_report', 'supervisorCartableReport')->name('supervisorCartableReport')->middleware('permission:show-fast-react-province|show-fast-react');
|
||||
Route::get('/operator_index','operatorIndex')->name('operatorIndex')->middleware('permission:show-fast-react-edarate-shahri');
|
||||
Route::get('/operator_report','operatorCartableReport')->name('operatorCartableReport')->middleware('permission:show-fast-react-edarate-shahri');
|
||||
Route::get('/complaints_index', 'complaintsIndex')
|
||||
->middleware('permission:show-fast-react-edarate-shahri|show-fast-react-province|show-fast-react')
|
||||
->name('complaintsIndex');
|
||||
Route::post('/register/{roadObserved}', 'register')
|
||||
->middleware('permission:show-fast-react-edarate-shahri|show-fast-react-province|show-fast-react')
|
||||
->middleware('permission:show-fast-react-edarate-shahri')
|
||||
->name('register');
|
||||
Route::post('/refer/{roadObserved}', 'refer')
|
||||
->middleware('permission:show-fast-react-edarate-shahri|show-fast-react-province|show-fast-react')
|
||||
->name('refer');
|
||||
|
||||
Route::get('/refer_list/{roadObserved}', 'referList')->name('referList');
|
||||
Route::get('/refer_list/{roadObserved}', 'referList')
|
||||
->middleware('permission:show-fast-react-edarate-shahri|show-fast-react-province|show-fast-react')
|
||||
->name('referList');
|
||||
|
||||
Route::post('/restore/{roadObserved}', 'restore')
|
||||
->middleware('permission:restore-fast-react')
|
||||
->name('restore');
|
||||
Route::get('/complaints_report', 'complaintsReport')->name('complaintsReport');
|
||||
|
||||
Route::get('/complaints_report', 'complaintsReport')->name('complaintsReport')
|
||||
->middleware('permission:show-fast-react-edarate-shahri|show-fast-react-province|show-fast-react');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user