/** * Returns a list of all the categories belonging to a user. * * @return Collection */ public function getCategories() : Collection { /** @var Collection $set */ $set = $this->user->categories()->orderBy('name', 'ASC')->get(); $set = $set->sortBy(function (Category $category) { return strtolower($category->name); }); return $set; }