61 lines
1.6 KiB
PHP
61 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo\Aisles;
|
|
|
|
use App\Rules\WysiwygLength;
|
|
use App\Traits\Requests\HasPicture;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class StoreAisleRequest extends FormRequest
|
|
{
|
|
use HasPicture;
|
|
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return auth('backend')->check();
|
|
}
|
|
|
|
/**
|
|
* Prepare the data for validation.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function prepareForValidation(): void
|
|
{
|
|
$this->merge([
|
|
'published' => $this->boolean('published')
|
|
]);
|
|
$this->mergePicture('picture');
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
$rules = [
|
|
'name' => 'required|string|between:3,255',
|
|
'title' => 'required|string|between:3,255',
|
|
'text' => [
|
|
'required',
|
|
'string',
|
|
new WysiwygLength(3, 500),
|
|
],
|
|
'picture_alt' => 'required|string|between:3,255',
|
|
'picture_title' => 'required|string|between:3,255',
|
|
'network_id' => 'required|exists:networks,id',
|
|
'published' => 'required|boolean',
|
|
];
|
|
return \array_merge(
|
|
$rules,
|
|
$this->pictureRules('picture', 1400, 450, 1400, 450, false),
|
|
);
|
|
}
|
|
}
|