This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions\Regulacao;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class CannotCancelSolicitacaoException extends Exception
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'A solicitação não pode ser cancelada.';
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return response()->json([
|
||||
'message' => $this->message
|
||||
], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions\Regulacao;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class CannotCreateSolicitacaoException extends Exception
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Necessário cadastrar pelo menos um Status com o tipo SOLICITADO.';
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return response()->json([
|
||||
'message' => $this->message
|
||||
], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions\Regulacao;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class CannotStoreSolicitacaoException extends Exception
|
||||
{
|
||||
protected $itens;
|
||||
|
||||
public function __construct(array $itens)
|
||||
{
|
||||
$this->itens = $itens;
|
||||
$this->message = 'O(s) seguinte(s) procedimento(s) já foi(ram) solicitado(s): <strong>'
|
||||
. implode(', ', $this->formatItens($itens))
|
||||
. '</strong>. Deseja continuar?';
|
||||
|
||||
}
|
||||
|
||||
protected function formatItens(array $itens)
|
||||
{
|
||||
return array_map(function ($item) {
|
||||
return $item['nome'] ?? 'Item desconhecido';
|
||||
}, $itens);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return response()->json([
|
||||
'message' => $this->message,
|
||||
'itens' => $this->formatItens($this->itens)
|
||||
], Response::HTTP_CONFLICT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions\Regulacao;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class CannotUpdateSolicitacaoException extends Exception
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'A solicitação não pode ser atualizada.';
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return response()->json([
|
||||
'message' => $this->message
|
||||
], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions\Regulacao;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class CannotUpdateSolicitacoesException extends Exception
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'As solicitações não podem ser atualizadas.';
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return response()->json([
|
||||
'message' => $this->message
|
||||
], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
21
api/app/Exceptions/Regulacao/StatusVinculadoException.php
Normal file
21
api/app/Exceptions/Regulacao/StatusVinculadoException.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions\Regulacao;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class StatusVinculadoException extends Exception
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'O status não pode ser excluído, pois está vinculado a outro(s)';
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return response()->json([
|
||||
'message' => $this->message
|
||||
], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user