Introduced a new class ServiceResultSuccess to distinctively handle successful service responses. Changes were made in AuthService and Service base class to replace ServiceResultArray with ServiceResultSuccess for successful operations. This provides a more accurate response type and improves code readability.

This commit is contained in:
2023-07-06 21:54:10 +06:00
parent c18e7e54b7
commit 91810190b7
3 changed files with 20 additions and 4 deletions

View File

@@ -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