87 lines
2.3 KiB
PHP
87 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo\Concepts;
|
|
|
|
use App\Http\Requests\Bo\UpdateMiniCrudRequest;
|
|
use App\Traits\Requests\HasPicture;
|
|
use Illuminate\Support\Str;
|
|
|
|
class StoreConceptRequest extends UpdateMiniCrudRequest
|
|
{
|
|
use HasPicture;
|
|
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize()
|
|
{
|
|
return auth('backend')->check();
|
|
}
|
|
|
|
/**
|
|
* Prepare the data for validation.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function prepareForValidation()
|
|
{
|
|
$this->merge([
|
|
'slug' => Str::slug(strip_tags($this->name))
|
|
]);
|
|
$this->mergePicture('picture');
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
$rules = [
|
|
'seo_title' => 'required|min:3|max:70',
|
|
'seo_description' => 'required|min:50|max:160',
|
|
|
|
'name' => 'required|min:3|max:70',
|
|
'title' => 'required|min:3|max:70',
|
|
'subtitle' => 'required|min:3|max:70',
|
|
'description' => 'required|string|min:15',
|
|
'data' => 'present|array',
|
|
'data.*' => 'required|array',
|
|
|
|
'picture_alt' => 'required|min:3|max:255',
|
|
'picture_title' => 'required|min:3|max:255',
|
|
];
|
|
return \array_merge(
|
|
$rules,
|
|
$this->pictureRules('picture', true, 1512, 354, 1512, 354),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function attributes()
|
|
{
|
|
return [
|
|
'seo_title' => trans('titre') . ' seo',
|
|
'seo_description' => trans('description') . ' seo',
|
|
|
|
'name' => trans('name of the concept'),
|
|
'slug' => trans('slug of the concept'),
|
|
'title' => trans('title of the concept'),
|
|
'subtitle' => trans('subtitle of the concept'),
|
|
'description' => trans('description of the concept'),
|
|
'data' => trans('values of the data'),
|
|
'data.*.value' => trans('value of the data'),
|
|
|
|
'picture' => trans('illustration'),
|
|
'picture_alt' => trans('alt attribute of the image'),
|
|
'picture_title' => trans('title attribute of the image'),
|
|
];
|
|
}
|
|
}
|