public function findBySlugWithArticlesPaginated($slug, $limit = 5) { $category = $this->category->where('slug', $slug)->first(); $articles = Article::with('author')->where('category_id', $category->id)->paginate($limit); return collect(['category' => $category, 'articles' => $articles]); }
protected function getArticles() { return Cache::remember('home:articles', static::CACHE_DURATION, function () { return Article::with('author')->where('published', 1)->latest()->take(3)->get(); }); }