ldc-boutique-cnc/app/Http/Requests/Fo/ContactFormRequest.php

59 lines
1.5 KiB
PHP
Raw Normal View History

2021-04-06 12:56:54 +02:00
<?php
2022-10-03 17:13:44 +02:00
namespace App\Http\Requests\Fo;
2021-04-06 12:56:54 +02:00
2023-02-16 16:59:51 +01:00
use App\Lib\Helpers\ToolboxHelper;
2021-04-06 12:56:54 +02:00
use Illuminate\Foundation\Http\FormRequest;
class ContactFormRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
2022-08-25 12:26:43 +02:00
* @return boolean
2021-04-06 12:56:54 +02:00
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
2023-02-16 16:59:51 +01:00
ToolboxHelper::validateRecaptcha($this, \config('services.google.recaptcha.version'));
2021-04-06 12:56:54 +02:00
return [
2022-12-06 12:59:34 +01:00
'firstname' => 'required|min:2|max:255',
'lastname' => 'required|min:2|max:255',
'subject' => 'required|min:2|max:255',
'email' => 'required|email:rfc,dns,spoof|max:255',
2021-04-06 12:56:54 +02:00
'message' => 'required|min:20|max:1900',
2022-12-06 12:59:34 +01:00
'order_number' => 'nullable|max:255',
'file' => 'nullable|mimes:jpg,jpeg,png,pdf|max:2048',
2021-04-06 12:56:54 +02:00
'ok_cgv' => 'accepted',
];
}
/**
2022-12-06 12:59:34 +01:00
* Get custom attributes for validator errors.
2021-04-06 12:56:54 +02:00
*
* @return array
*/
2022-12-06 12:59:34 +01:00
public function attributes()
2021-04-06 12:56:54 +02:00
{
return [
2022-12-06 12:59:34 +01:00
'firstname' => trans('Prénom'),
'lastname' => trans('Nom'),
2023-02-27 17:20:27 +01:00
'subject' => trans('Objet'),
2022-12-06 12:59:34 +01:00
'email' => trans('E-mail'),
'message' => trans('Message'),
'order_number' => trans('Numéro de commande'),
'file' => trans('Pièce jointe'),
'ok_cgv' => trans('Conditions d\'utilisation')
2021-04-06 12:56:54 +02:00
];
}
}