debug the index method
This commit is contained in:
@@ -38,12 +38,10 @@ class RoadMaintenanceStationController extends Controller
|
||||
|
||||
$query = RahdariPoint::with('files')
|
||||
->when($status, fn ($query, $status) => $query->where('status', $status))
|
||||
->when($type, fn ($query, $type) => $query->where('type', $type));
|
||||
->when($type, fn ($query, $type) => $query->where('type', $type))
|
||||
->when($province, fn($query, $province) => $query->where('province_id', $province));
|
||||
|
||||
if ($user->can('show-tollhouse')) {
|
||||
$query->when($province, fn($query) => $query->where('province_id', $province));
|
||||
}
|
||||
elseif ($user->can('show-tollhouse-province')) {
|
||||
if ($user->hasPermissionTo('show-tollhouse-province')) {
|
||||
$query->where('province_id', $user->province_id);
|
||||
}
|
||||
|
||||
@@ -56,27 +54,23 @@ class RoadMaintenanceStationController extends Controller
|
||||
|
||||
|
||||
foreach ($data['data'] as &$stations) {
|
||||
if ($user->can('edit-tollhouse')) {
|
||||
if ($user->hasPermissionTo('edit-tollhouse')) {
|
||||
$stations['canEdit'] = 1;
|
||||
} elseif ($user->can('edit-tollhouse-province')) {
|
||||
if ($user->province_id) {
|
||||
$stations['canEdit'] = 1;
|
||||
} else {
|
||||
$stations['canEdit'] = 0;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
elseif ($user->hasPermissionTo('edit-tollhouse-province') && $stations->province_id == $user->province_id) {
|
||||
$stations['canEdit'] = 1;
|
||||
}
|
||||
else {
|
||||
$stations['canEdit'] = 0;
|
||||
}
|
||||
|
||||
if ($user->can('delete-tollhouse')) {
|
||||
if ($user->hasPermissionTo('delete-tollhouse')) {
|
||||
$stations['canDelete'] = 1;
|
||||
} elseif ($user->can('delete-tollhouse-province')) {
|
||||
if ($user->province_id) {
|
||||
$stations['canDelete'] = 1;
|
||||
} else {
|
||||
$stations['canDelete'] = 0;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
elseif ($user->hasPermissionTo('delete-tollhouse-province') && $stations->province_id == $user->province_id) {
|
||||
$stations['canDelete'] = 1;
|
||||
}
|
||||
else {
|
||||
$stations['canDelete'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,15 +392,9 @@ Route::prefix('Road-Maintenance-Station')
|
||||
->name('Road-Maintenance-Station.')
|
||||
->controller( RoadMaintenanceStationController::class)
|
||||
->group(function () {
|
||||
Route::get('/', 'index')->name('index')
|
||||
->middleware('permission:show-tollhouse|show-tollhouse-province');
|
||||
Route::post('/', 'store')->name('store')
|
||||
->middleware('permission:add-tollhouse|add-tollhouse-province');
|
||||
Route::get('/{rahdariPoint}', 'show')->name('show')
|
||||
->middleware('permission:show-tollhouse|show-tollhouse-province');
|
||||
Route::post('/{rahdariPoint}', 'update')->name('update')
|
||||
->middleware('permission:edit-tollhouse|edit-tollhouse-province');
|
||||
Route::delete('/{rahdariPoint}', 'destroy')->name('destroy')
|
||||
->middleware('permission:delete-tollhouse|delete-tollhouse-province');
|
||||
|
||||
Route::get('/', 'index')->name('index')->middleware('permission:show-tollhouse|show-tollhouse-province');
|
||||
Route::post('/', 'store')->name('store')->middleware('permission:add-tollhouse|add-tollhouse-province');
|
||||
Route::get('/{rahdariPoint}', 'show')->name('show')->middleware('permission:show-tollhouse|show-tollhouse-province');
|
||||
Route::post('/{rahdariPoint}', 'update')->name('update')->middleware('permission:edit-tollhouse|edit-tollhouse-province');
|
||||
Route::delete('/{rahdariPoint}', 'destroy')->name('destroy')->middleware('permission:delete-tollhouse|delete-tollhouse-province');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user