本文整理汇总了PHP中app\models\Post::paginate方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::paginate方法的具体用法?PHP Post::paginate怎么用?PHP Post::paginate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Post
的用法示例。
在下文中一共展示了Post::paginate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//$posts = Post::all();
$paginator = Post::paginate(9);
$posts = $paginator->getCollection();
$data = fractal()->collection($posts)->transformWith(new PostTransformer())->includeUser()->includeCategories()->paginateWith(new IlluminatePaginatorAdapter($paginator))->toArray();
return $this->respond($data);
}
示例2: estates
public function estates(Request $request)
{
$posts = Post::paginate($this->posts_per_page);
if ($request->ajax()) {
return ['posts' => view('ajax.estates', compact('posts'))->render(), 'next_page' => $posts->nextPageUrl()];
}
return view('estates', compact('posts'));
}
示例3: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$posts = Post::paginate(Input::get('itemPerPage'));
foreach ($posts as $post) {
$post = array_except($post, array("body"));
$teacher = Teacher::find($post->author_id);
$category_id = CategoryPost::wherePost_id($post->id)->first()->category_id;
$category = Category::find($category_id)->name;
$post['category_id'] = $category_id;
$post['category'] = $category;
$post['author'] = $teacher->name;
$post['fb'] = $teacher->fb;
}
return $posts;
}
示例4: getIndex
public function getIndex(Request $req, $page = 1)
{
/*if (Auth::check())
{
//dd(Auth::user());
$user = Auth::user();
echo $user->id;
dd(Auth::user());
exit;
} else {
return 'Guest';
}*/
$data = Post::paginate(2);
$data->setPath('post');
$data->lastPage();
return view('admins.posts.dashboard', compact('data'));
}
示例5: index
public function index()
{
$posts = Post::paginate(15);
return view('posts.list', array('posts' => $posts));
}
示例6: index
public function index()
{
$posts = $this->post->paginate(10);
return view('admin.index', ['posts' => $posts]);
}
示例7: index
public function index()
{
$posts = Post::paginate(10);
return view('home', array('posts' => $posts));
}
示例8: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$posts = Post::paginate(10);
// dd($posts->toArray());
return view('site.blog.index')->with('posts', $posts);
}
示例9: index
public function index()
{
$posts = $this->post->paginate(5);
return view('home.index', ['posts' => $posts]);
}