fraserk's avatar

L5 Paginator

I'm trying to create a pagination link in a L5 application

When I try to output the pagination.

$data->links()

I getting the following error..

Call to undefined method Illuminate\Database\Query\Builder::links()

Anyone know if pagination has change in L5..

Thanks..

0 likes
4 replies
bashy's avatar

Are the fields set in the JSON array if you return the paginated data?

fraserk's avatar

This is what is being returned.

object(Illuminate\Pagination\Paginator)[217]
  protected 'factory' => 
    object(Illuminate\Pagination\Factory)[204]
      protected 'request' => 
        object(Illuminate\Http\Request)[3]
          protected 'json' => null
          protected 'sessionStore' => null
          public 'attributes' => 
            object(Symfony\Component\HttpFoundation\ParameterBag)[6]
              ...
          public 'request' => 
            object(Symfony\Component\HttpFoundation\ParameterBag)[4]
              ...
          public 'query' => 
            object(Symfony\Component\HttpFoundation\ParameterBag)[5]
              ...
          public 'server' => 
            object(Symfony\Component\HttpFoundation\ServerBag)[9]
              ...
          public 'files' => 
            object(Symfony\Component\HttpFoundation\FileBag)[8]
              ...
          public 'cookies' => 
            object(Symfony\Component\HttpFoundation\ParameterBag)[7]
              ...
          public 'headers' => 
            object(Symfony\Component\HttpFoundation\HeaderBag)[10]
              ...
          protected 'content' => null
          protected 'languages' => null
          protected 'charsets' => null
          protected 'encodings' => null
          protected 'acceptableContentTypes' => 
            array (size=5)
              ...
          protected 'pathInfo' => string '/' (length=1)
          protected 'requestUri' => string '/' (length=1)
          protected 'baseUrl' => string '' (length=0)
          protected 'basePath' => null
          protected 'method' => string 'GET' (length=3)
          protected 'format' => null
          protected 'session' => 
            object(Illuminate\Session\Store)[107]
              ...
          protected 'locale' => null
          protected 'defaultLocale' => string 'en' (length=2)
      protected 'view' => 
        object(Illuminate\View\Factory)[138]
          protected 'engines' => 
            object(Illuminate\View\Engines\EngineResolver)[109]
              ...
          protected 'finder' => 
            object(Illuminate\View\FileViewFinder)[137]
              ...
          protected 'events' => 
            object(Illuminate\Events\Dispatcher)[14]
              ...
          protected 'container' => 
            object(Illuminate\Foundation\Application)[2]
              ...
          protected 'shared' => 
            array (size=3)
              ...
          protected 'aliases' => 
            array (size=0)
              ...
          protected 'names' => 
            array (size=0)
              ...
          protected 'extensions' => 
            array (size=2)
              ...
          protected 'composers' => 
            array (size=0)
              ...
          protected 'sections' => 
            array (size=0)
              ...
          protected 'sectionStack' => 
            array (size=0)
              ...
          protected 'renderCount' => int 0
      protected 'trans' => 
        object(Illuminate\Translation\Translator)[211]
          protected 'loader' => 
            object(Illuminate\Translation\FileLoader)[210]
              ...
          protected 'locale' => string 'en' (length=2)
          protected 'fallback' => string 'en' (length=2)
          protected 'loaded' => 
            array (size=0)
              ...
          protected 'parsed' => 
            array (size=0)
              ...
      protected 'viewName' => string 'pagination::slider-3' (length=20)
      protected 'currentPage' => null
      protected 'locale' => null
      protected 'baseUrl' => null
      protected 'pageName' => string 'page' (length=4)
  protected 'items' => 
    array (size=4)
      0 => 
        object(App\Evnt)[214]
          public 'fillable' => 
            array (size=7)
              ...
          protected 'dates' => string 'deleted_at' (length=10)
          protected 'table' => string 'events' (length=6)
          protected 'connection' => null
          protected 'primaryKey' => string 'id' (length=2)
          protected 'perPage' => int 15
          public 'incrementing' => boolean true
          public 'timestamps' => boolean true
          protected 'attributes' => 
            array (size=13)
              ...
          protected 'original' => 
            array (size=13)
              ...
          protected 'relations' => 
            array (size=0)
              ...
          protected 'hidden' => 
            array (size=0)
              ...
          protected 'visible' => 
            array (size=0)
              ...
          protected 'appends' => 
            array (size=0)
              ...
          protected 'guarded' => 
            array (size=1)
              ...
          protected 'touches' => 
            array (size=0)
              ...
          protected 'observables' => 
            array (size=0)
              ...
          protected 'with' => 
            array (size=0)
              ...
          protected 'morphClass' => null
          public 'exists' => boolean true
          protected 'forceDeleting' => boolean false
      1 => 
        object(App\Evnt)[192]
          public 'fillable' => 
            array (size=7)
              ...
          protected 'dates' => string 'deleted_at' (length=10)
          protected 'table' => string 'events' (length=6)
          protected 'connection' => null
          protected 'primaryKey' => string 'id' (length=2)
          protected 'perPage' => int 15
          public 'incrementing' => boolean true
          public 'timestamps' => boolean true
          protected 'attributes' => 
            array (size=13)
              ...
          protected 'original' => 
            array (size=13)
              ...
          protected 'relations' => 
            array (size=0)
              ...
          protected 'hidden' => 
            array (size=0)
              ...
          protected 'visible' => 
            array (size=0)
              ...
          protected 'appends' => 
            array (size=0)
              ...
          protected 'guarded' => 
            array (size=1)
              ...
          protected 'touches' => 
            array (size=0)
              ...
          protected 'observables' => 
            array (size=0)
              ...
          protected 'with' => 
            array (size=0)
              ...
          protected 'morphClass' => null
          public 'exists' => boolean true
          protected 'forceDeleting' => boolean false
      2 => 
        object(App\Evnt)[218]
          public 'fillable' => 
            array (size=7)
              ...
          protected 'dates' => string 'deleted_at' (length=10)
          protected 'table' => string 'events' (length=6)
          protected 'connection' => null
          protected 'primaryKey' => string 'id' (length=2)
          protected 'perPage' => int 15
          public 'incrementing' => boolean true
          public 'timestamps' => boolean true
          protected 'attributes' => 
            array (size=13)
              ...
          protected 'original' => 
            array (size=13)
              ...
          protected 'relations' => 
            array (size=0)
              ...
          protected 'hidden' => 
            array (size=0)
              ...
          protected 'visible' => 
            array (size=0)
              ...
          protected 'appends' => 
            array (size=0)
              ...
          protected 'guarded' => 
            array (size=1)
              ...
          protected 'touches' => 
            array (size=0)
              ...
          protected 'observables' => 
            array (size=0)
              ...
          protected 'with' => 
            array (size=0)
              ...
          protected 'morphClass' => null
          public 'exists' => boolean true
          protected 'forceDeleting' => boolean false
      3 => 
        object(App\Evnt)[219]
          public 'fillable' => 
            array (size=7)
              ...
          protected 'dates' => string 'deleted_at' (length=10)
          protected 'table' => string 'events' (length=6)
          protected 'connection' => null
          protected 'primaryKey' => string 'id' (length=2)
          protected 'perPage' => int 15
          public 'incrementing' => boolean true
          public 'timestamps' => boolean true
          protected 'attributes' => 
            array (size=13)
              ...
          protected 'original' => 
            array (size=13)
              ...
          protected 'relations' => 
            array (size=0)
              ...
          protected 'hidden' => 
            array (size=0)
              ...
          protected 'visible' => 
            array (size=0)
              ...
          protected 'appends' => 
            array (size=0)
              ...
          protected 'guarded' => 
            array (size=1)
              ...
          protected 'touches' => 
            array (size=0)
              ...
          protected 'observables' => 
            array (size=0)
              ...
          protected 'with' => 
            array (size=0)
              ...
          protected 'morphClass' => null
          public 'exists' => boolean true
          protected 'forceDeleting' => boolean false
  protected 'total' => int 4
  protected 'hasMore' => null
  protected 'perPage' => int 30
  protected 'currentPage' => int 1
  protected 'lastPage' => int 1
  protected 'from' => int 1
  protected 'to' => int 4
  protected 'query' => 
    array (size=0)
      empty
  protected 'fragment' => null

fraserk's avatar
fraserk
OP
Best Answer
Level 16

My fault. I had a typo in my code..

1 like

Please or to participate in this conversation.