warn('This will delete all users from the system that are not "admin" or system users.'); $confirm = $this->confirm('Are you sure you want to continue?'); if (!$confirm) { return 0; } $totalUsers = User::query()->count(); $numDeleted = 0; $users = User::query()->whereNull('system_name')->with('roles')->get(); foreach ($users as $user) { if ($user->hasSystemRole('admin')) { // don't delete users with "admin" role continue; } $userRepo->destroy($user); $numDeleted++; } $this->info("Deleted $numDeleted of $totalUsers total users."); return 0; } }