-
-
Save juniordias-planejar/8efd3d66bee6140a990da84e686f4177 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Modules\Base\AclGrupoUsuarios; | |
use Illuminate\Http\Request; | |
class AclGrupoUsuariosRequest | |
{ | |
/** | |
* Get the validation rules that apply to the request. | |
* | |
* @return array | |
*/ | |
public function rules(Request $request): array | |
{ | |
$id = (int) $request->route('id'); | |
$primaryKey = $id > 0 ? ",${id}=codi_acl_grup_usu_sequ" : ''; | |
return [ | |
'codi_acl_grup_sequ' => "required|integer|max:4294967296|unique_with:pgsql.base.acl_grupo_usuarios,codi_usu_sequ,codi_inst_sequ${primaryKey}", | |
'codi_usu_sequ' => 'required|integer|max:4294967296', | |
'codi_inst_sequ' => 'required|integer|max:4294967296', | |
]; | |
} | |
/** | |
* Get custom attributes for validator errors. | |
* | |
* @return array | |
*/ | |
public function attributes(): array | |
{ | |
return [ | |
'codi_acl_grup_sequ' => 'Grupo', | |
'codi_usu_sequ' => 'Usuario', | |
'codi_inst_sequ' => 'Instituicao', | |
]; | |
} | |
/** | |
* Get the error messages for the defined validation rules. | |
* | |
* @return array | |
*/ | |
public function messages(): array | |
{ | |
return ['codi_acl_grup_sequ.unique_with' => 'Já existe um registro com os parâmetros informados.']; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment