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