title: pagination and factory in laravel4
body: <p>Consider this code taken from <a href="http://www.codeheaps.com/php-programming/creating-blog-using-laravel-4-part-2/" rel="nofollow">here</a>.</p>
  
  <pre><code> public function getIndex() 
   {
       $posts = Post::orderBy('id','desc')-&gt;paginate(10);
       // For Laravel 4.2 use getFactory() instead of getEnvironment() method.
       $posts-&gt;getEnvironment()-&gt;setViewName('pagination::simple');
       $this-&gt;layout-&gt;title = 'Home Page | Laravel 4 Blog';
       $this-&gt;layout-&gt;main = View::make('home')-&gt;nest('content','index',compact('posts'));
   }
  </code></pre>
  
  <p>As I understand it, pagination limits the number of rows, so I think paginate(10) means select first ten rows in the database. But I absolutely don't understand this.</p>
  
  <pre><code>     // For Laravel 4.2 use getFactory() instead of getEnvironment() method.
       $posts-&gt;getEnvironment()-&gt;setViewName('pagination::simple');
  </code></pre>
  
  <p>or</p>
  
  <pre><code>     $posts-&gt;getFactory()-&gt;setViewName('pagination::simple');
  </code></pre>
  
  <p>And everything below. Mainly I don't understand what factory means and how it relates to pagination. I went to the laravel docs  on <a href="http://laravel.com/api/4.2/Illuminate/Pagination/Factory.html" rel="nofollow">Illuminate\Pagination\Factory</a> and <a href="http://laravel.com/api/4.2/Illuminate/View/View.html#method_getFactory" rel="nofollow">Illuminate\View\View</a> but I can't find the meaning of factory. Can anyone explain the code above?</p>