user = $user; $this->userRepo = $userRepo; parent::__construct(); } public function handle() { $confirm = $this->ask('This will delete all users from the system that are not "admin" or system users. Are you sure you want to continue? (Type "yes" to continue)'); $numDeleted = 0; if (strtolower(trim($confirm)) === 'yes') { $totalUsers = $this->user->count(); $users = $this->user->where('system_name', '=', null)->with('roles')->get(); foreach ($users as $user) { if ($user->hasSystemRole('admin')) { // don't delete users with "admin" role continue; } $this->userRepo->destroy($user); $numDeleted++; } $this->info("Deleted $numDeleted of $totalUsers total users."); } else { $this->info('Exiting...'); } } }