diff --git a/app/ServiceResults/ServiceResultSuccess.php b/app/ServiceResults/ServiceResultSuccess.php new file mode 100644 index 0000000..7a6a3c6 --- /dev/null +++ b/app/ServiceResults/ServiceResultSuccess.php @@ -0,0 +1,15 @@ +message; + } +} diff --git a/app/Services/AuthService.php b/app/Services/AuthService.php index 03dc196..6542546 100644 --- a/app/Services/AuthService.php +++ b/app/Services/AuthService.php @@ -4,8 +4,8 @@ namespace App\Services; use App\Dto\Request\Authorization; use App\Repositories\UserRepository; -use App\ServiceResults\ServiceResultArray; use App\ServiceResults\ServiceResultError; +use App\ServiceResults\ServiceResultSuccess; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; @@ -15,7 +15,7 @@ final class AuthService extends Service private readonly UserRepository $userRepository ) { } - public function authorization(Authorization $authorization): ServiceResultError | ServiceResultArray + public function authorization(Authorization $authorization): ServiceResultError | ServiceResultSuccess { $user = $this->userRepository->getUserByEmail($authorization->getEmail()); if (is_null($user)) { diff --git a/app/Services/Service.php b/app/Services/Service.php index d844c35..f7bb5f9 100644 --- a/app/Services/Service.php +++ b/app/Services/Service.php @@ -5,6 +5,7 @@ namespace App\Services; use App\ServiceResults\ServiceResultArray; use App\ServiceResults\ServiceResultError; +use App\ServiceResults\ServiceResultSuccess; use Illuminate\Http\Response; abstract class Service @@ -39,9 +40,9 @@ abstract class Service return $this->error(Response::HTTP_UNAUTHORIZED, $message); } - final protected function ok(string $message = 'OK'): ServiceResultArray + final protected function ok(string $message = 'OK'): ServiceResultSuccess { - return $this->result(['message' => $message]); + return new ServiceResultSuccess($message); } final protected function result(array $data = []): ServiceResultArray