Articles::paginate(10)
This code will return the 1st 10 articles, what if I want to return the next 10 articles with route? For example the url mypage.com/articles/2 will return the 2nd 10 articles from database.
This is so far what I have:
Route:
Route::get('articles/{page_number}', 'Controller@getArticles')
Controller:
public function getArticles($page_num)
{
$perPage = 10;
Articles::getPaginator()->setCurrentPage($page_num);
$articles = Articles::paginate($perPage);
return $articles;
}
Can I have something like Articles::pageNumber($page_number)->paginate($perPage);?