diff --git a/app/Console/Commands/DeleteUsers.php b/app/Console/Commands/DeleteUsers.php index c287dd55e..8829d3992 100644 --- a/app/Console/Commands/DeleteUsers.php +++ b/app/Console/Commands/DeleteUsers.php @@ -39,11 +39,11 @@ class DeleteUsers extends Command{ $numDeleted = 0; if (strtolower(trim($confirm)) === 'yes') { - $totalUsers = User::count(); + $totalUsers = $this->user->count(); $users = $this->user->where('system_name', '=', null)->with('roles')->get(); foreach ($users as $user) { - if ($user->hasRole('admin')) + if ($user->hasSystemRole('admin')) { // don't delete users with "admin" role continue; diff --git a/app/Repos/UserRepo.php b/app/Repos/UserRepo.php index c3546a442..52ad2e47e 100644 --- a/app/Repos/UserRepo.php +++ b/app/Repos/UserRepo.php @@ -115,9 +115,9 @@ class UserRepo */ public function isOnlyAdmin(User $user) { - if (!$user->roles->pluck('name')->contains('admin')) return false; + if (!$user->hasSystemRole('admin')) return false; - $adminRole = $this->role->getRole('admin'); + $adminRole = $this->role->getSystemRole('admin'); if ($adminRole->users->count() > 1) return false; return true; }