0

When I am using laravel Collection & DB query pagination. getting the following error.

new UserCollection(DB::table('users')->paginate());

e

I am using elequent pagination as follows,

new UserCollection(User::paginate());

It works fine as follows.

en

I have upgraded from Laravel 5.8 to 6.

4
  • 1
    The user paginated is already a collection itself. why are you creating a collection over your pagination? . if you returns an ajax then the collection get lost and only will return an object Commented Oct 4, 2019 at 2:28
  • This is API resource response to format API response. Commented Oct 4, 2019 at 4:22
  • You need to convert stdClass to array. Here is your answer. Commented Oct 4, 2019 at 7:16
  • this is general solution but how can I apply this here. API resource Commented Oct 4, 2019 at 10:13

1 Answer 1

0

Try is one

 User::paginate();
You need to convert stdClass to array
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.