48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?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,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'title' => 'required',
|
|
'picture' => 'sometimes|image|mimes:jpeg,png,jpg|max:2048|dimensions:width=1920,height=878',
|
|
'alt_text_picture' => 'required|max:255',
|
|
'url' => 'nullable|required_if:new_tab,true|url',
|
|
'new_tab' => 'required_with:url|boolean',
|
|
'status' => 'nullable|boolean'
|
|
];
|
|
}
|
|
}
|