2024-01-05 17:36:16 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Bo\Settings;
|
|
|
|
|
|
|
|
|
|
use App\Traits\Requests\HasPicture;
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
use Illuminate\Support\Facades\Gate;
|
2024-09-03 10:24:31 +02:00
|
|
|
use App\Rules\Hex;
|
2024-01-05 17:36:16 +01:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
*/
|
2025-07-08 16:15:25 +02:00
|
|
|
protected function prepareForValidation(): void
|
2024-01-05 17:36:16 +01:00
|
|
|
{
|
|
|
|
|
$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
|
|
|
|
|
{
|
2025-07-08 16:15:25 +02:00
|
|
|
$numberOfLocales = count(config('app.locales'));
|
|
|
|
|
$rules = [
|
|
|
|
|
'locales' => "required|array|between:1,$numberOfLocales",
|
|
|
|
|
'sub_title' => "required|array|between:0,$numberOfLocales",
|
|
|
|
|
'sub_title.*' => 'nullable|min:2|max:110',
|
|
|
|
|
'footer_phrase' => "required|array|between:1,$numberOfLocales",
|
|
|
|
|
'footer_phrase.*' => 'required|min:2|max:110',
|
|
|
|
|
'color' => ['required', new Hex()],
|
|
|
|
|
'home_timeout' => 'required|numeric|min:20|max:900',
|
2024-01-05 17:36:16 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return \array_merge(
|
|
|
|
|
$rules,
|
2024-03-13 15:16:25 +01:00
|
|
|
$this->pictureRules('logo', 420, 500, 420, 500, false)
|
2024-01-05 17:36:16 +01:00
|
|
|
);
|
|
|
|
|
}
|
2024-01-05 17:39:04 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get custom attributes for validator errors.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function attributes(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
2025-07-08 16:15:25 +02:00
|
|
|
'locales' => \trans('validation.custom.locales'),
|
|
|
|
|
'color' => \trans('validation.custom.color'),
|
|
|
|
|
'logo' => \trans('validation.custom.logo'),
|
|
|
|
|
'home_timeout' => \trans('validation.custom.home_timeout'),
|
|
|
|
|
'sub_title.*' => \trans('validation.custom.sub_title'),
|
|
|
|
|
'footer_phrase.*' => \trans('validation.custom.footer_phrase'),
|
2024-01-05 17:39:04 +01:00
|
|
|
];
|
|
|
|
|
}
|
2024-01-05 17:36:16 +01:00
|
|
|
}
|