ldc-legaulois/app/Http/Requests/StoreActuRequest.php

46 lines
1.3 KiB
PHP
Raw Normal View History

2021-09-20 18:41:41 +02:00
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Str;
class StoreActuRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
2022-02-10 16:14:58 +01:00
* @return boolean
2021-09-20 18:41:41 +02:00
*/
public function authorize()
{
$this->merge([
'status' => $this->status ? true : false,
'slug' => Str::slug($this->title),
]);
return auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'title' => 'required|string|min:20|max:255',
'slug' => 'required|unique:actus,slug|max:255',
'seo_title' => 'required|string|min:20|max:255',
'seo_description' => 'required|string|min:20|max:255',
'picture' => 'required|image|max:2048|mimes:png,jpg,jpeg|dimensions:height=611,width=916',
2021-09-20 18:41:41 +02:00
'picture_alt' => 'required|string|min:5|max:255',
'header' => 'required|string',
'content' => 'required|string|min:20',
'status' => 'required|boolean',
2021-09-20 21:50:37 +02:00
'tags' => 'sometimes|array',
'tags.*' => 'required_with:tags|numeric|exists:tags,id'
2021-09-20 18:41:41 +02:00
];
}
}