File manager - Edit - /var/www/html/portal/app/Http/Requests/Mobiangra/MobiangraManifestacaoRequest.php
Back
<?php namespace App\Http\Requests\Mobiangra; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Rule; class MobiangraManifestacaoRequest extends FormRequest { public function authorize(): bool { return auth()->check(); } /** * @return array<string, mixed> */ public function rules(): array { $relatoMax = (int) config('mobiangra.manifestacao_relato_max', 2000); $uploadMaxKb = (int) config('mobiangra.manifestacao_imagem_upload_max_kb', 10240); return [ 'linha' => ['nullable', 'string', 'max:120'], 'sentido' => ['nullable', 'string', 'max:80', Rule::in(['ida', 'volta', 'nao_informado'])], 'horario' => ['nullable', 'string', 'max:40'], 'local' => ['nullable', 'string', 'max:255'], 'numero_veiculo' => ['nullable', 'string', 'max:40'], 'relato' => ['required', 'string', 'max:' . $relatoMax], 'imagem' => ['nullable', 'image', 'mimes:jpg,jpeg,png,webp', 'max:' . $uploadMaxKb], 'lgpd_consentimento' => ['accepted'], 'g-recaptcha-response' => [config('recaptcha.enabled') ? 'required' : 'nullable', 'string'], ]; } /** * @return array<string, string> */ public function attributes(): array { return [ 'linha' => __('Linha'), 'sentido' => __('Sentido'), 'horario' => __('Horário'), 'local' => __('Local'), 'numero_veiculo' => __('Número do veículo'), 'relato' => __('Relato'), 'imagem' => __('Imagem'), 'lgpd_consentimento' => __('Termo de proteção de dados'), 'g-recaptcha-response' => __('Verificação de segurança'), ]; } /** * @return array<string, string> */ public function messages(): array { $uploadMaxMb = number_format( (int) config('mobiangra.manifestacao_imagem_upload_max_kb', 10240) / 1024, 1, ',', '' ); return [ 'required' => 'O campo :attribute é obrigatório.', 'max.string' => 'O campo :attribute não pode ter mais de :max caracteres.', 'imagem.image' => 'O arquivo enviado deve ser uma imagem válida.', 'imagem.mimes' => 'Formato de imagem não permitido. Utilize JPG, PNG ou WEBP.', 'imagem.max' => 'A imagem enviada excede o limite de '.$uploadMaxMb.' MB no envio. Tente outra foto.', 'sentido.in' => 'Selecione um sentido válido.', 'lgpd_consentimento.accepted' => 'É necessário aceitar o termo de proteção de dados para enviar a manifestação.', 'g-recaptcha-response.required' => 'Complete a verificação de segurança antes de enviar.', ]; } protected function prepareForValidation(): void { $this->merge([ 'linha' => trim((string) $this->input('linha')) ?: null, 'horario' => trim((string) $this->input('horario')) ?: null, 'local' => trim((string) $this->input('local')) ?: null, 'numero_veiculo' => trim((string) $this->input('numero_veiculo')) ?: null, 'relato' => trim((string) $this->input('relato')), ]); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings