user()->canManageCategories(); } public function rules(): array { $categoryId = $this->route('category')?->id; return [ 'name' => ['required', 'string', 'max:100'], 'slug' => [ 'nullable', 'string', 'max:100', 'regex:/^[a-z0-9-]+$/', Rule::unique('categories', 'slug')->ignore($categoryId)->whereNull('deleted_at'), ], 'description' => ['nullable', 'string', 'max:500'], 'color' => ['nullable', 'string', 'regex:/^#[0-9A-Fa-f]{6}$/'], 'is_active' => ['boolean'], 'sort_order' => ['nullable', 'integer', 'min:0'], ]; } public function messages(): array { return [ 'name.required' => 'Nama kategori wajib diisi.', 'slug.unique' => 'Slug ini sudah digunakan.', 'slug.regex' => 'Slug hanya boleh mengandungi huruf kecil, angka, dan tanda (-)', 'color.regex' => 'Warna mesti dalam format hex (contoh: #3b82f6)', ]; } }