本文整理匯總了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]);
}