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