This commit is contained in:
24
api/app/Rules/Sigtap/ProcedimentoExists.php
Normal file
24
api/app/Rules/Sigtap/ProcedimentoExists.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules\Sigtap;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ProcedimentoExists implements Rule
|
||||
{
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
return self::isValid($value);
|
||||
}
|
||||
|
||||
public static function isValid($value)
|
||||
{
|
||||
return DB::table('sigtap.procedimento')->where('id', $value)->exists();
|
||||
}
|
||||
|
||||
public function message()
|
||||
{
|
||||
return 'Procedimento inválido.';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user