php - pagination and factory in laravel4 -


consider code taken here.

 public function getindex()   {      $posts = post::orderby('id','desc')->paginate(10);      // laravel 4.2 use getfactory() instead of getenvironment() method.      $posts->getenvironment()->setviewname('pagination::simple');      $this->layout->title = 'home page | laravel 4 blog';      $this->layout->main = view::make('home')->nest('content','index',compact('posts'));  } 

as understand it, pagination limits number of rows, think paginate(10) means select first ten rows in database. absolutely don't understand this.

     // laravel 4.2 use getfactory() instead of getenvironment() method.      $posts->getenvironment()->setviewname('pagination::simple'); 

or

     $posts->getfactory()->setviewname('pagination::simple'); 

and below. don't understand factory means , how relates pagination. went laravel docs on illuminate\pagination\factory , illuminate\view\view can't find meaning of factory. can explain code above?

you setting how pagination output in html selecting specific paginator view, allows have more 1 type in application or use different default.

using multiple pagination types in same application

sometimes, may want use different pagination types across application. default, laravel use type specified in app/config/view.php file, need override setting when wish use type. here how so.

// code should in controller or route closure. // let’s use old example of list of blog posts.  $articles = article::paginate(5);  paginator::setviewname('pagination::simple');  /* alternatively, use achieve same result:  $articles->getenvironment()->setviewname('pagination::simple');  know what’s happening under hood, here more detailed explanation:  1. calling paginate() on eloquent model or query builder return    instance of \illuminate\pagination\paginator  2. then, need related \illuminate\pagination\environment of    paginator via well-named getenvironment() method.  3. finally, can specify pagination type need. default value    'pagination::slider'.  pagination types available default located in vendor/laravel/framework/src/illuminate/pagination/views directory. */ 

source: http://laravel-tricks.com/tricks/using-multiple-pagination-types-in-the-same-application


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -