> */ public function rules(): array { return [ 'name' => ['required', 'string', 'max:255'], 'percent' => ['required', 'numeric', 'min:0', 'max:100'], 'active' => ['sometimes', 'boolean'], 'pos' => ['nullable', 'integer', 'min:0', 'max:255'], ]; } protected function prepareForValidation(): void { $this->merge([ 'active' => $this->boolean('active'), 'pos' => $this->input('pos', '') === '' ? 0 : $this->input('pos'), ]); } }