/** * Get all categories with their posts counts. * * @return \Illuminate\Support\Collection */ public function getAllWithPostsCounts() { return $this->model->with(['postsCount'])->get(); }