Update graduation workflow, promotions, and admin module improvements
This commit is contained in:
@@ -30,6 +30,11 @@ class UserManagementController extends Controller
|
||||
'users' => $users,
|
||||
'search' => $search,
|
||||
'roleOptions' => $this->roleOptions(),
|
||||
'stats' => [
|
||||
'total' => User::count(),
|
||||
'admins' => User::where('role', 'admin')->count(),
|
||||
'staff' => User::where('role', 'staff')->count(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -77,10 +82,14 @@ class UserManagementController extends Controller
|
||||
public function destroy(Request $request, User $user): RedirectResponse
|
||||
{
|
||||
if ((int) $request->user()->id === (int) $user->id) {
|
||||
Alert::error('Tidak bisa dihapus', 'Akun yang sedang dipakai login tidak bisa dihapus.');
|
||||
|
||||
return back()->withErrors(['user' => 'Akun yang sedang dipakai login tidak bisa dihapus.']);
|
||||
}
|
||||
|
||||
if (User::query()->where('role', 'admin')->count() <= 1 && $user->role === 'admin') {
|
||||
Alert::error('Tidak bisa dihapus', 'Minimal harus ada satu akun admin aktif di sistem.');
|
||||
|
||||
return back()->withErrors(['user' => 'Minimal harus ada satu akun admin aktif di sistem.']);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user