Skip to content
Advertisement

Paginating with laravel collection in api

I got problem in Laravel Api collection paginate.

I have categories and I need to bring all products that belongs to a single category

My code:

JavaScript

The code of paginate in AppServiceProvider at boot method

JavaScript

The result in first page is fine:

JavaScript

The problem in the second page( the number key of the data( 10 , 11 ) before each product i need to remove it!

JavaScript

Advertisement

Answer

You can try pagination in eloquent resources, so instead of creating custom paginate, you can do like this:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement