This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules\AtencaoBasica\Exportacao;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ProcedimentoIsDuplicate implements Rule
|
||||
{
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
return self::isValid($value);
|
||||
}
|
||||
|
||||
public static function isValid($value)
|
||||
{
|
||||
$result = DB::table('atencao_basica_procedimento_atendimento_procedimento')
|
||||
->where('procedimento_atendimento_id', $value->procedimento_atendimento_id)
|
||||
->where('procedimento_id', $value->procedimento_id)
|
||||
->count();
|
||||
|
||||
return $result > 1;
|
||||
}
|
||||
|
||||
public function message()
|
||||
{
|
||||
return 'Procedimento em duplicidade.';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user