I am trying to paginate Model result, but I am getting \"Method paginate does not exist.\". Here is my code:
$user_dispatches = Dispatch::all()->where(\'user_
Extending a bit Alexey's perfect answer :
Dispatch::all()
=> Returns aCollection
Dispatch::all()->where()
=> Returns aCollection
Dispatch::where()
=> Returns aQuery
Dispatch::where()->get()
=> Returns aCollection
Dispatch::where()->get()->where()
=> Returns aCollection
You can only invoke "paginate
" on a Query
, not on a Collection
.
And yes, it is totally confusing to have a where
function for both Queries
and Collections
, working as close as they do, but it is what it is.