56 lines
1.6 KiB
PHP
56 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use App\Enums\ContactFormCivility;
|
|
use App\Enums\ContactFormType;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Kwaadpepper\Enum\Rules\EnumIsValidRule;
|
|
|
|
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()
|
|
{
|
|
if ($this->type == ContactFormType::onepage()->value) {
|
|
app()->setLocale('nl');
|
|
}
|
|
return [
|
|
'civility' => [
|
|
'required',
|
|
new EnumIsValidRule(ContactFormCivility::class)
|
|
],
|
|
'type' => [
|
|
'required',
|
|
new EnumIsValidRule(ContactFormType::class)
|
|
],
|
|
// * max arcadia 50 chars
|
|
'lastname' => 'required|min:2|max:50',
|
|
// * max arcadia 50 chars
|
|
'firstname' => 'required|min:2|max:50',
|
|
'address' => 'required|min:4',
|
|
'email' => 'required|email:rfc,dns,spoof',
|
|
'postal' => 'required|min:3|max:10',
|
|
// * max arcadia 10 chars
|
|
'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:2048'
|
|
];
|
|
}
|
|
}
|