Files
rkm-conectasus-ci-sandbox/api/app/Rules/Sigtap/CidIsRelatedToProcedimento.php
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

35 lines
831 B
PHP

<?php
namespace App\Rules\Sigtap;
use Illuminate\Contracts\Validation\Rule;
use Illuminate\Support\Facades\DB;
class CidIsRelatedToProcedimento implements Rule
{
private $procedimentoId;
public function __construct($procedimentoId)
{
$this->procedimentoId = $procedimentoId;
}
public function passes($attribute, $value)
{
return self::isValid($this->procedimentoId, $value);
}
public static function isValid($procedimentoId, $cidId)
{
return DB::table('sigtap.procedimento_cid as procedimento_cid')
->where('procedimento_cid.procedimento_id', $procedimentoId)
->where('procedimento_cid.cid_id', $cidId)
->exists();
}
public function message()
{
return 'CID inválido para o procedimento informado.';
}
}