search

Home  >  Q&A  >  body text

How to query the first 50 data in laravel's Eloquent ORM

$product = Product::all();

This is to investigate and deal with all products

I want to output 50 pieces of data on the html page first;

When the user pulls down, go to ajax to query the subsequent data

html page data, how to query the first 50 data

And there are conditions. The product must be on the shelves

阿神阿神2757 days ago534

reply all(1)I'll reply

  • PHPz

    PHPz2017-05-16 16:58:07

    Paging$product = Product::paginate(50);passed to blade through view
    Pass variables $pos, $limit when pulling down to refresh $product = Product::where([])->skip($pos)->take($limit)->get();

    reply
    0
  • Cancelreply