<?php
 namespace App\Http\Requests\Admin\Settings; use App\Models\ClientCustomField; use Illuminate\Foundation\Http\FormRequest; class StoreClientCustomFieldRequest extends FormRequest { public function authorize(): bool { return $this->user()->can('create', ClientCustomField::class); } public function rules(): array { return [ 'name' => ['required', 'string', 'max:255'], 'type' => ['required', 'string', 'in:input,select'], 'description' => ['nullable', 'string'], 'is_required' => ['sometimes', 'boolean'], 'show_in_order' => ['sometimes', 'boolean'], 'show_in_clientarea' => ['sometimes', 'boolean'], 'show_in_invoice' => ['sometimes', 'boolean'], 'client_locked' => ['sometimes', 'boolean'], ]; } public function attributes(): array { return [ 'name' => __('admin/client-custom-fields.fields_name'), 'type' => __('admin/client-custom-fields.fields_type'), 'description' => __('admin/client-custom-fields.fields_description'), 'is_required' => __('admin/client-custom-fields.fields_is_required'), 'show_in_order' => __('admin/client-custom-fields.fields_show_in_order'), 'show_in_clientarea' => __('admin/client-custom-fields.fields_show_in_clientarea'), 'show_in_invoice' => __('admin/client-custom-fields.fields_show_in_invoice'), ]; } protected function prepareForValidation(): void { $this->merge([ 'is_required' => $this->boolean('is_required'), 'show_in_order' => $this->boolean('show_in_order'), 'show_in_clientarea' => $this->boolean('show_in_clientarea'), 'show_in_invoice' => $this->boolean('show_in_invoice'), 'client_locked' => $this->boolean('client_locked'), ]); } } 