ldc-legaulois/app/Http/Requests/Bo/GeneralSettings/UpdateGeneralSettingRequest.php
2024-04-09 12:38:19 +02:00

56 lines
1.2 KiB
PHP

<?php
namespace App\Http\Requests\Bo\GeneralSettings;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Gate;
class UpdateGeneralSettingRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
return Gate::check('update', $this->route('general_setting'));
}
/**
* Prepare the data for validation.
*
* @return void
*/
public function prepareForValidation(): void
{
$this->merge([
'value' => json_decode($this->input('jsonValue', '[]'))
]);
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'jsonValue' => 'required|json',
'value' => 'required'
];
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes(): array
{
return [
'value' => trans('validation.custom.value')
];
}
}