Files
Antonio Lopes dos Santos afec302c3e
All checks were successful
build-api-image / build (push) Successful in 51s
init commit
2026-08-04 16:52:02 -03:00

30 lines
854 B
PHP

<?php
namespace App\Rules\Cadastro\SujeitoAtencao;
use App\Models\Cadastro\SujeitoAtencao\Paciente;
use Illuminate\Contracts\Validation\Rule;
class PacienteRequireEndereco implements Rule
{
public function passes($attribute, $value)
{
return Paciente::where('id', $value)
->whereHas('cidadao.domicilio.endereco', function($query) {
$query->whereNotNull('numero');
})
->whereHas('cidadao.domicilio.endereco.logradouro', function($query) {
$query->has('municipio')
->has('bairro')
->has('tipo')
->whereNotNull('nome')
->whereNotNull('cep');
})->exists();
}
public function message()
{
return 'Endereço inconsistente para o paciente selecionado.';
}
}