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