ldc-doux/app/Http/Requests/StoreSliderRequest.php

62 lines
1.2 KiB
PHP
Raw Normal View History

2021-12-06 08:51:51 +01:00
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
2021-12-07 23:35:14 +01:00
use Illuminate\Support\Str;
2021-12-06 08:51:51 +01:00
class StoreSliderRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
2022-08-11 12:34:27 +02:00
* @return boolean
2021-12-06 08:51:51 +01:00
*/
public function authorize()
{
2021-12-07 23:35:14 +01:00
$this->merge([
'slug' => Str::slug($this->label),
'published' => $this->published ? true : false
]);
return auth()->check();
2021-12-06 08:51:51 +01:00
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'label' => 'required|string|max:255',
2021-12-07 23:35:14 +01:00
'slug' => 'required|unique:sliders',
'commentaire' => 'sometimes|max:255',
'published' => 'required|boolean',
];
}
/**
* Get custom messages for validator errors.
*
* @return array
*/
public function messages()
{
return [];
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes()
{
return [
'slug' => trans('label')
2021-12-06 08:51:51 +01:00
];
}
}