|string> */ public function rules(): array { $categoryId = $this->route('client_category')?->id; return [ 'name' => [ 'required', 'string', 'max:255', Rule::unique('client_categories')->ignore($categoryId) ], 'slug' => [ 'nullable', 'string', 'max:255', 'alpha_dash', Rule::unique('client_categories')->ignore($categoryId) ], 'description' => 'nullable|string|max:1000', 'is_active' => 'boolean', 'sort_order' => 'nullable|integer|min:0', ]; } public function attributes(): array { return [ 'name' => 'category name', 'slug' => 'URL slug', ]; } protected function prepareForValidation(): void { // Generate slug from name if not provided and name exists if (!$this->slug && $this->name) { $this->merge([ 'slug' => \Str::slug($this->name), ]); } // Ensure boolean values are properly cast if ($this->has('is_active')) { $this->merge([ 'is_active' => filter_var($this->is_active, FILTER_VALIDATE_BOOLEAN), ]); } } }