feat: tambah role koordinator dengan akses buat/edit/hapus kegiatan milik sendiri
This commit is contained in:
@@ -36,7 +36,20 @@ class UserForm
|
||||
->columnSpanFull(),
|
||||
DatePicker::make('last_activity_date')->label('Terakhir Aktif'),
|
||||
Select::make('roles')->relationship('roles', 'name')
|
||||
->multiple()->preload()->label('Role'),
|
||||
->multiple()->preload()->label('Role')
|
||||
->getOptionLabelFromRecordUsing(fn ($record) => $record->name)
|
||||
->options(function () {
|
||||
$user = auth()->user();
|
||||
$query = \Spatie\Permission\Models\Role::query()
|
||||
->whereNotIn('name', ['super_admin', 'panel_user']);
|
||||
|
||||
// Hanya ketua (AssignKoordinator) yang bisa assign role koordinator
|
||||
if (! $user->can('AssignKoordinator')) {
|
||||
$query->where('name', '!=', 'koordinator');
|
||||
}
|
||||
|
||||
return $query->pluck('name', 'id');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user