slug = Str::slug($category->name); }); static::updating(function ($category) { $category->slug = Str::slug($category->name); }); } /** * Get the subcategories for the category. */ public function subcategories() { return $this->hasMany(Subcategory::class); } /** * Get the cafes for the category. */ public function cafes() { return $this->hasMany(Cafe::class); } }