fix: hapus hardcode role, ganti dengan permission check (can())
This commit is contained in:
@@ -17,7 +17,7 @@ class ActivitiesTable
|
||||
{
|
||||
return $table
|
||||
->modifyQueryUsing(function ($query) {
|
||||
if (! auth()->user()->hasRole('super_admin')) {
|
||||
if (! auth()->user()->can('ViewDraft:Activity')) {
|
||||
$query->where(fn ($q) => $q
|
||||
->where('status', '!=', 'draft')
|
||||
->orWhere('created_by', auth()->id())
|
||||
@@ -60,7 +60,7 @@ class ActivitiesTable
|
||||
->color('success')
|
||||
->requiresConfirmation()
|
||||
->visible(fn ($record) => $record->status === 'pending'
|
||||
&& auth()->user()->hasAnyRole(['ketua', 'super_admin']))
|
||||
&& auth()->user()->can('Update:Activity'))
|
||||
->action(fn ($record) => $record->update([
|
||||
'status' => 'approved',
|
||||
'approved_by' => auth()->id(),
|
||||
@@ -72,7 +72,7 @@ class ActivitiesTable
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->visible(fn ($record) => $record->status === 'pending'
|
||||
&& auth()->user()->hasAnyRole(['ketua', 'super_admin']))
|
||||
&& auth()->user()->can('Update:Activity'))
|
||||
->action(fn ($record) => $record->update(['status' => 'rejected'])),
|
||||
])
|
||||
->toolbarActions([BulkActionGroup::make([DeleteBulkAction::make()])]);
|
||||
|
||||
Reference in New Issue
Block a user