本文整理汇总了PHP中Post::paginate方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::paginate方法的具体用法?PHP Post::paginate怎么用?PHP Post::paginate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post::paginate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$validator = Validator::make(Input::all(), Post::$rules);
if ($validator->fails()) {
Session::flash('errorMessage', 'Something went wrong here!');
return Redirect::back()->withErrors($validator)->withInput();
} else {
$post = new Post();
$post->title = Input::get('title');
$post->body = Input::get('body');
$post->user_id = Auth::id();
if (Input::hasFile('picture')) {
if (Input::file('picture')->isValid()) {
Storage::upload(Input::file('picture'), "{$post->picture}" . "jpg");
}
$post->picture = Input::file('picture');
}
if (Input::has('tags')) {
$post->tags = implode(', ', Input::get('tags'));
}
$post->save();
$posts = Post::paginate(5);
Session::flash('goodMessage', 'All went right here!');
return View::make('posts/index')->with('posts', $posts);
}
}
示例2: index
/**
* Display a listing of the resource.
*
* @return Index View
*/
public function index()
{
$posts = Post::paginate(5);
// if(!$post->count() === 0){
// Session::flash('errorMessage', 'There were no results matching your search.');
// }
return View::make('posts.index')->with('posts', $posts);
}
示例3: index
public function index()
{
$data["_title"] = array("top" => "最新消息", "main" => "Home", "sub" => "post");
$data["active"] = "news";
$cate_array = array();
$cates = Cate::where("type", "!=", "工程進度")->get();
foreach ($cates as $cate) {
$cate_array[$cate->id] = $cate->name;
}
$data["cates"] = $cate_array;
$data["result"] = Post::paginate(10);
return View::make('admin.posts.index', $data);
}
示例4: getPosts
/**
* Get all posts
* @param int $perPage $posts
* @return JSON
*/
public function getPosts($perPage)
{
// get posts
$posts = Post::paginate($perPage);
// paginatation array
$postsResponse['total'] = $posts->getTotal();
$postsResponse['per_page'] = $posts->getPerPage();
$postsResponse['current_page'] = $posts->getCurrentPage();
$postsResponse['last_page'] = $posts->getLastPage();
$postsResponse['from'] = $posts->getFrom();
$postsResponse['to'] = $posts->getTo();
// self link
$postsResponse['links'] = ['self' => action('PostController@index')];
// data param
foreach ($posts as $post) {
$postsResponse['data'][] = ['type' => 'posts', 'id' => $post->id, 'attributes' => $post];
}
// Create Response header
$response = Response::make($postsResponse, 200);
$response->header('Content-Type', 'application/vnd.api+json');
return $response;
}
示例5: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$posts = Post::paginate(6);
return View::make('posts.index')->with(array('posts' => $posts));
}
示例6: paginate
public function paginate($limit = null)
{
return Post::paginate($limit);
}
示例7: index
/**
* Display a listing of the resource.
* GET /post
*
* @return Response
*/
public function index()
{
$posts = Post::paginate(3);
return View::make('admin.posts.post-list', compact('posts'));
}
示例8: showIndex
public function showIndex()
{
$posts = Post::paginate(4);
return View::make('posts.index')->with(['posts' => $posts]);
}
示例9: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
#get all posts
$posts = Post::paginate(10);
return View::make('blog')->with('posts', $posts);
}
示例10: index
public function index()
{
$r_slide = Slideshow::all();
$r_post = Post::paginate(3);
return View::make('pages.home', compact('r_post', 'r_slide'));
}