Made authorization.

This commit is contained in:
2023-07-06 10:48:32 +06:00
parent 6b2aff910b
commit f481ee765d
17 changed files with 356 additions and 5 deletions

View File

@@ -5,32 +5,38 @@ namespace App\Services;
use App\ServiceResults\ServiceResultArray;
use App\ServiceResults\ServiceResultError;
use Illuminate\Http\Response;
abstract class Service
{
final protected function errValidate(string $message, array $errors = []): ServiceResultError
{
return $this->error(422, $message, $errors);
return $this->error(Response::HTTP_UNPROCESSABLE_ENTITY, $message, $errors);
}
final protected function errFobidden(string $message): ServiceResultError
{
return $this->error(403, $message);
return $this->error(Response::HTTP_FORBIDDEN, $message);
}
final protected function errNotFound(string $message): ServiceResultError
{
return $this->error(404, $message);
return $this->error(Response::HTTP_NOT_FOUND, $message);
}
final protected function errService(string $message): ServiceResultError
{
return $this->error(500, $message);
return $this->error(Response::HTTP_INTERNAL_SERVER_ERROR, $message);
}
final protected function notAcceptable(string $message): ServiceResultError
{
return $this->error(406, $message);
return $this->error(Response::HTTP_NOT_ACCEPTABLE, $message);
}
final protected function errUnauthorized(string $message): ServiceResultError
{
return $this->error(Response::HTTP_UNAUTHORIZED, $message);
}
final protected function ok(string $message = 'OK'): ServiceResultArray