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

65 lines
1.5 KiB
PHP

<?php
namespace App\Http\Requests\Bo\Settings;
use App\Traits\Requests\HasPicture;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Gate;
class UpdateSettingsRequest extends FormRequest
{
use HasPicture;
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
return Gate::allows('update', $this->route('settings'));
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation()
{
$this->mergePicture('logo');
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
*/
public function rules(): array
{
$rules = [
'title' => 'required|min:2|max:60',
'color' => 'required|color_hex',
'items_by_line' => 'required|numeric|min:3|max:6',
];
return \array_merge(
$rules,
$this->pictureRules('logo', 200, 200, 200, 200, false)
);
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes(): array
{
return [
'color' => \trans('validation.custom.color'),
'logo' => \trans('validation.custom.logo'),
'items_by_line' => \trans('validation.custom.items_by_line'),
];
}
}