Advertisement
SanderCokart

recentArticles

Mar 8th, 2022
688
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.41 KB | None | 0 0
  1. public function recent(Request $request, ArticleType $articleType): ArticleCollection
  2.     {
  3.         $request->validate([
  4.             'articleType' => 'string|in:posts,tips-&-tutorials'
  5.         ]);
  6.  
  7.         return new ArticleCollection(Article::with(['author', 'status', 'banner'])
  8.             ->published()
  9.             ->whereBelongsTo($articleType)
  10.             ->latest()
  11.             ->cursorPaginate(10));
  12.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement