ldc-legaulois/app/Http/Requests/ContactFormRequest.php
Jérémy Munsch db234ced3d Add One page
- add npm jquery, fancybox, jquery-devrama-slider-2 (forked)
     odometer, owl.carousel
 -  compile onepage.js app-onepage.css
 - Onepage Controller, calls ContactController to use form
 -  change app default locale to 'fr'
 - add more resources assets (images, documents flamand)
 - add more icons svg
2021-02-17 16:48:08 +01:00

62 lines
2 KiB
PHP

<?php
namespace App\Http\Requests;
use App\Enums\ContactFormCivility;
use App\Enums\ContactFormType;
use Illuminate\Foundation\Http\FormRequest;
class ContactFormRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'civility' => [
'required',
function ($attribute, $value, $fail) {
if (!in_array($value, ContactFormCivility::toValues())) {
$fail(__('Veuillez choisir entre :values', [
'value' => implode(',', ContactFormCivility::toLabels())
]));
}
}
],
'type' => [
'required',
function ($attribute, $value, $fail) {
if (!in_array($value, ContactFormType::toValues())) {
$fail(__('Veuillez choisir entre :values', [
'value' => implode(',', ContactFormType::toLabels())
]));
}
}
],
'lastname' => 'required|min:2',
'firstname' => 'required|min:2',
'address' => 'required|min:4',
// TODO: The dns and spoof validators require the PHP intl extension. (présent sur prod ?)
'email' => 'required|email:rfc,dns,spoof',
'postal' => 'required|min:3|max:12',
'town' => 'required|min:3|max:90',
'phone' => 'required|min:8|max:14',
'onepagesubject' => 'sometimes|min:10|max:250',
'message' => 'required|min:20|max:1900',
'joinFile' => 'nullable|mimes:jpg,jpeg,png,pdf|max:3145728'
];
}
}