ldc-domaine-de-lanvaux/app/Http/Requests/StoreHomepageSlideRequest.php

49 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2022-08-05 09:38:44 +00:00
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreHomepageSlideRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
return auth()->check();
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation()
{
$this->merge([
'new_tab' => $this->new_tab ? true : false,
'status' => $this->status ? true : false,
]);
}
2022-08-05 09:38:44 +00:00
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
return [
'title' => 'required',
2022-11-08 15:03:13 +01:00
'picture' => 'sometimes|image|mimes:jpeg,png,jpg|max:2048|dimensions:width=1920,height=878',
2022-08-05 09:38:44 +00:00
'alt_text_picture' => 'required|max:255',
'url' => 'nullable|required_if:new_tab,true|url',
'new_tab' => 'required_with:url|boolean',
'status' => 'nullable|boolean'
2022-08-05 09:38:44 +00:00
];
}
}