当前位置: 首页>>代码示例>>PHP>>正文


PHP Post::paginate方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:perenchiod,项目名称:Portfolio-Blog,代码行数:31,代码来源:PostsController.php

示例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);
 }
开发者ID:sprov03,项目名称:blog.dev,代码行数:13,代码来源:PostsController.php

示例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);
 }
开发者ID:nvizero,项目名称:beautifulbuild,代码行数:13,代码来源:PostController.php

示例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;
 }
开发者ID:amirmasoud,项目名称:API,代码行数:27,代码来源:postService.php

示例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));
 }
开发者ID:ThomasNYoung,项目名称:Blog-,代码行数:10,代码来源:PostsController.php

示例6: paginate

 public function paginate($limit = null)
 {
     return Post::paginate($limit);
 }
开发者ID:valdinei,项目名称:nettuts-laravel4-and-backbone,代码行数:4,代码来源:EloquentPostRepository.php

示例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'));
 }
开发者ID:yusufdemir,项目名称:L4StartKit,代码行数:11,代码来源:PostController.php

示例8: showIndex

 public function showIndex()
 {
     $posts = Post::paginate(4);
     return View::make('posts.index')->with(['posts' => $posts]);
 }
开发者ID:asteph,项目名称:Laravel_Blog,代码行数:5,代码来源:HomeController.php

示例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);
 }
开发者ID:jakeols,项目名称:blog,代码行数:11,代码来源:PostsController.php

示例10: index

 public function index()
 {
     $r_slide = Slideshow::all();
     $r_post = Post::paginate(3);
     return View::make('pages.home', compact('r_post', 'r_slide'));
 }
开发者ID:hendryguna,项目名称:laravel-basic,代码行数:6,代码来源:HomeController.php


注:本文中的Post::paginate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。