本文整理汇总了PHP中app\models\Article::paginate方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::paginate方法的具体用法?PHP Article::paginate怎么用?PHP Article::paginate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Article
的用法示例。
在下文中一共展示了Article::paginate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$articles = Article::paginate(20);
if (Request::ajax()) {
return \Response::json(view("blog", compact("articles"))->render());
}
return view("blog", compact("articles"));
}
示例2: index
/**
* Show the application dashboard.
*
* @return Response
*/
public function index()
{
$perPage = 2;
$article = Article::paginate($perPage);
$maxPage = intval(ceil(Article::count() / $perPage));
$firstArticle = $article->shift();
$others = $article;
return view('home')->with(['first' => $firstArticle, 'others' => $others, 'maxPage' => $maxPage]);
/*$categories = Category::all();
$articles = Article::paginate(15);
return view('home')->withArticles($articles)->withCategories($categories);*/
}
示例3: index
public function index()
{
if (empty(Input::get('category'))) {
$categories = Category::all();
$articles = Article::paginate(15);
return view('article.index')->withArticles($articles)->withCategories($categories);
} else {
$category = Input::get('category');
$articles = Category::where('name', $category)->article;
return view('article.index')->withArticles($articles)->withCategories($category);
}
}
示例4: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
return view('admin.articles.index')->with('articles', Article::paginate(10));
}