ldc-gen-game-web/app/Http/Requests/Bo/Ranges/StoreRangeRequest.php
2026-10-20 12:27:49 +02:00

54 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Requests\Bo\Ranges;
use App\Models\Range;
use App\Traits\Requests\HasPicture;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Gate;
class StoreRangeRequest extends FormRequest
{
use HasPicture;
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return Gate::check('create', Range::class);
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation()
{
$this->mergePicture('picture');
}
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
$rules = [
'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',
];
$width = config('theme.models.ranges.picture_max_width');
$height = config('theme.models.ranges.picture_max_height');
return \array_merge(
$rules,
$this->pictureRules('picture', $width, $height, $width, $height, false),
);
}
}