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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user