whereDate('valid_until', '>', Carbon::now())->get(); $this->table(['id', 'token', 'authenticated', 'valid_until'], $authTokens); $response = $this->ask('Token ID to escalate:'); if (strlen($response) === 0) { $this->info('Nothing entered, exiting.'); return 0; } if (!is_numeric($response)) { $this->info('Invalid input entered, exiting.'); return 1; } $id = (int)$response; $token = AuthenticationToken::find($id); if ($token === null) { $this->info('Invalid token ID given, exiting.'); return 1; } $targetRole = $this->choice('Should this token be a manager or normal user?', ['user', 'manager']); $authState = ['manager' => true, 'user' => false][$targetRole]; $token->authenticated = $authState; $token->save(); if ($authState) { $this->info('Token ' . $id . ' escalated to manager.'); } else { $this->info('Token ' . $id . ' deescalated to user.'); } return 0; } }