ldc-boutique-cnc/app/Http/Requests/ContactFormRequest.php
2022-08-25 12:26:43 +02:00

52 lines
1.4 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class ContactFormRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'last_name' => 'required|min:2',
'first_name' => 'required|min:2',
// TODO: The dns and spoof validators require the PHP intl extension. (présent sur prod ?)
'email' => 'required|email:rfc,dns,spoof',
'subject' => 'required|min:2',
'order_ref' => 'sometimes',
'message' => 'required|min:20|max:1900',
'file' => 'nullable|mimes:jpg,jpeg,png,pdf|max:5120',
'ok_cgv' => 'accepted',
];
}
/**
* Get the error messages for the defined validation rules.
*
* @return array
*/
public function messages()
{
return [
'ok_cgv.accepted' => __('You must accept the terms and conditions and the privacy policy'),
'file.max' => __('La taille du fichier ne peut pas dépasser :max kilo-octets.'),
'file.mimes' => __('Le fichier doit être de type : :values.'),
];
}
}