provider = $provider; $this->authService = $authService; } public function check() { return $this->authService->loggedIn(); } public function guest() { return ! $this->check(); } public function user() { if ($this->user !== null) { return $this->user; } if ($this->authService->loggedIn()) { $this->user = $this->provider->retrieveById($this->authService::getUserId()); } return $this->user; } public function hasUser() { return $this->user ? true : false; } public function id() { return $this->user()?->getAuthIdentifier(); } public function validate(array $credentials = []) { return $this->authService->login( $credentials['username'], $credentials['password'] ); } public function setUser(Authenticatable $user) { $this->user = $user; return $this; } }