45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?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.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
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',
|
|
'picture_alt' => 'required|string|min:5|max:255',
|
|
'header' => 'required|string',
|
|
'content' => 'required|string|min:20',
|
|
'status' => 'required|boolean',
|
|
'tags' => 'sometimes|array',
|
|
'tags.*' => 'required_with:tags|numeric|exists:tags,id'
|
|
];
|
|
}
|
|
}
|