'required', 'slug' => $this->getSlugRules(), 'is_active' => 'required|boolean', 'is_active' => 'required|boolean', ]; } private function getSlugRules() { $rules = $this->route()->getName() === 'admin.categories.update' ? ['required'] : ['nullable']; $slug = Category::withoutGlobalScope('active')->where('id', $this->id)->value('slug'); $rules[] = Rule::unique('categories', 'slug')->ignore($slug, 'slug'); return $rules; } }