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

67 lines
1.6 KiB
PHP
Raw Normal View History

2021-12-20 17:21:09 +01:00
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
2021-12-21 17:30:39 +01:00
use Illuminate\Support\Str;
2021-12-20 17:21:09 +01:00
class StoreGammeRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
2021-12-21 17:30:39 +01:00
$this->merge([
'slug' => Str::slug($this->title),
'parent_gamme_id' => $this->parent_gamme_id === '0' ? null : $this->parent_gamme_id,
]);
2021-12-20 17:21:09 +01:00
return auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
2021-12-21 17:30:39 +01:00
'parent_gamme_id' => 'sometimes|nullable|exists:gammes,id',
'title' => 'required|string|max:255',
'slug' => 'required|unique:gammes',
'text' => 'required|string|max:255',
2021-12-20 17:21:09 +01:00
'color' => 'sometimes',
'picture' => 'required|image|mimes:jpeg,png,jpg|max:1024|dimensions:width=575,height=375',
2021-12-21 17:30:39 +01:00
'alt_text_picture' => 'required|string|max:255',
2021-12-24 15:58:59 +01:00
'banner' => 'required|image|mimes:jpeg,png,jpg|max:2048|dimensions:width=1920,height=568',
2021-12-21 17:30:39 +01:00
'alt_text_banner' => 'required|string|max:255',
];
}
/**
* 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('Nom')
2021-12-20 17:21:09 +01:00
];
}
}