ldc-showroom-bo/app/Http/Requests/Bo/Ranges/StoreRangeRequest.php
2024-01-05 17:39:04 +01:00

63 lines
1.3 KiB
PHP

<?php
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 boolean
*/
public function authorize(): bool
{
return Gate::allows('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.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
*/
public function rules(): array
{
$rules = [
'name' => 'required|min:2|max:90',
'brand_id' => 'required|exists:brands,id'
];
return \array_merge(
$rules,
$this->pictureRules('picture', 500, 500, 800, 500, false)
);
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes(): array
{
return [
'brand_id' => \trans_choice('models.classes.brand', 1),
];
}
}