This commit is contained in:
44
api/app/Rules/Sigtap/Procedimento/Sexo.php
Normal file
44
api/app/Rules/Sigtap/Procedimento/Sexo.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules\Sigtap\Procedimento;
|
||||
|
||||
use App\Models\Cadastro\SujeitoAtencao\Sexo as CidadaoSexo;
|
||||
use App\Models\Sigtap\Procedimento;
|
||||
use App\Services\Sigtap\ProcedimentoValidationService;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class Sexo implements Rule
|
||||
{
|
||||
private CidadaoSexo $sexo;
|
||||
private Procedimento $procedimento;
|
||||
|
||||
public function __construct(Procedimento $procedimento, CidadaoSexo $sexo)
|
||||
{
|
||||
$this->procedimento = $procedimento;
|
||||
$this->sexo = $sexo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
$validation = new ProcedimentoValidationService($this->procedimento);
|
||||
|
||||
return $validation->isSexoValid($this->sexo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return ":attribute não permitido para o sexo do paciente.";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user