File manager - Edit - /var/www/html/portal/app/Http/Requests/IndicadoresTiClienteRequest.php
Back
<?php namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Validator; /** * Validação do cadastro rápido de cliente do módulo IndicadoresTI * (endpoint JSON admin.indicadoresTi.clientes.store). */ class IndicadoresTiClienteRequest extends FormRequest { public function authorize(): bool { return true; } /** * @return array<string, array<int, string>> */ public function rules(): array { return [ 'nome' => ['required', 'string', 'max:255'], 'cpf' => ['nullable', 'string', 'max:14'], 'matricula' => ['nullable', 'string', 'max:50'], 'setor' => ['nullable', 'string', 'max:255'], 'telefone' => ['nullable', 'string', 'max:50'], ]; } /** * @return array<string, string> */ public function messages(): array { return [ 'nome.required' => __('O nome é obrigatório.'), 'nome.max' => __('O nome deve ter no máximo 255 caracteres.'), 'cpf.max' => __('O CPF deve ter no máximo 14 caracteres.'), 'matricula.max' => __('A matrícula deve ter no máximo 50 caracteres.'), 'setor.max' => __('O setor deve ter no máximo 255 caracteres.'), 'telefone.max' => __('O telefone deve ter no máximo 50 caracteres.'), ]; } /** * Exige CPF ou matrícula para identificação do cliente. */ public function withValidator(Validator $validator): void { $validator->after(function (Validator $v) { if (!$this->filled('cpf') && !$this->filled('matricula')) { $v->errors()->add('cpf', __('Informe o CPF ou a Matrícula do cliente.')); } }); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings