2021-08-18 17:04:51 +02:00
|
|
|
<?php
|
|
|
|
|
|
2023-08-22 13:38:38 +02:00
|
|
|
namespace App\Http\Requests\Bo\Ranges;
|
2021-08-18 17:04:51 +02:00
|
|
|
|
2023-12-05 12:33:25 +01:00
|
|
|
use App\Models\Range;
|
2023-08-22 13:38:38 +02:00
|
|
|
use App\Traits\Requests\HasPicture;
|
2021-08-18 17:04:51 +02:00
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
2023-12-05 12:33:25 +01:00
|
|
|
use Illuminate\Support\Facades\Gate;
|
2021-08-18 17:04:51 +02:00
|
|
|
|
|
|
|
|
class StoreRangeRequest extends FormRequest
|
|
|
|
|
{
|
2023-08-22 13:38:38 +02:00
|
|
|
use HasPicture;
|
|
|
|
|
|
2021-08-18 17:04:51 +02:00
|
|
|
/**
|
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
|
*
|
2022-01-11 12:39:28 +01:00
|
|
|
* @return boolean
|
2021-08-18 17:04:51 +02:00
|
|
|
*/
|
|
|
|
|
public function authorize()
|
|
|
|
|
{
|
2023-12-05 12:33:25 +01:00
|
|
|
return Gate::check('create', Range::class);
|
2021-08-18 17:04:51 +02:00
|
|
|
}
|
|
|
|
|
|
2023-08-22 13:38:38 +02:00
|
|
|
/**
|
|
|
|
|
* Prepare the data for validation.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function prepareForValidation()
|
|
|
|
|
{
|
|
|
|
|
$this->mergePicture('picture');
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-18 17:04:51 +02:00
|
|
|
/**
|
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function rules()
|
|
|
|
|
{
|
2023-11-30 16:58:36 +01:00
|
|
|
$rules = [
|
2025-08-14 14:12:13 +00:00
|
|
|
'name' => 'required|string|min:2|max:255',
|
|
|
|
|
'picture_alt' => 'nullable|required_with:picture|string|between:3,255',
|
|
|
|
|
'picture_title' => 'nullable|required_with:picture|string|between:3,255',
|
2021-08-18 17:04:51 +02:00
|
|
|
];
|
2023-11-29 15:33:23 +01:00
|
|
|
$width = config('theme.models.ranges.picture_max_width');
|
|
|
|
|
$height = config('theme.models.ranges.picture_max_height');
|
2023-08-22 13:38:38 +02:00
|
|
|
return \array_merge(
|
|
|
|
|
$rules,
|
2023-11-29 15:33:23 +01:00
|
|
|
$this->pictureRules('picture', $width, $height, $width, $height, false),
|
2023-08-22 13:38:38 +02:00
|
|
|
);
|
2021-08-18 17:04:51 +02:00
|
|
|
}
|
|
|
|
|
}
|