Error Laravel Method paginate does not exist

0 votes

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_id', Auth::id())->paginate(10);

I need to get all records where users id equals current authenticated users id. Works well without paginate() method.

Dec 2, 2020 in JQuery by kartik
• 37,520 points
7,847 views

1 answer to this question.

0 votes

Hello @kartik,

Try this:

Dispatch::all() => Returns a Collection

Dispatch::all()->where() => Returns a Collection

Dispatch::where() => Returns a Query

Dispatch::where()->get() => Returns a Collection

Dispatch::where()->get()->where() => Returns a Collection

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.

answered Dec 2, 2020 by Niroj
• 82,840 points

Related Questions In JQuery

0 votes
1 answer

Why does jQuery or a DOM method such as getElementById not find the element?

At the moment the script is executed, ...READ MORE

answered Jun 1, 2022 in JQuery by Edureka
• 13,690 points
1,935 views
0 votes
1 answer

Error: cannot call methods on button prior to initialization; attempted to call method 'loading'

Hii @kartik, It's caused by jquery-ui and bootstrap-button ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,840 points
6,566 views
0 votes
1 answer

Error: cannot call methods on dialog prior to initialization; attempted to call method 'close'

Hello, Try this - it works for me: $(".editDialog").on("click", ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,840 points
1,351 views
0 votes
1 answer

Error:jQuery scrollTop not working in Chrome but working in Firefox

Hello @kartik, If your CSS html element has the following overflow markup, scrollTop will ...READ MORE

answered May 29, 2020 in JQuery by Niroj
• 82,840 points
14,831 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
23,012 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
2,995 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
2,918 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
44,696 views
0 votes
1 answer

Error: cannot call methods on dialog prior to initialization; attempted to call method 'close'

Hello @kartik, Looks like your buttons are not ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,840 points
8,936 views
0 votes
1 answer

Error: no such method 'show' for tooltip widget instance

Hello, The root of this and similar problem "no such method ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,840 points
3,663 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP