0

This code fetches all the data in the table in the database, but I want to set a maximum limit, for example, it fetches only 4 columns from the table so that it does not load all the columns in the table

   'productes' => productModel::orderBy('id', 'DESC')->get()

1 Answers1

0
 'productes' => productModel::orderBy('id', 'DESC')->limit(20)->get(['id',...])

Try this. But I'm highly recommended you read laravel documentation

limit is the count of rows that will be fetched from DB and get will fetch columns that you passed in the array

Aro
  • 1,078
  • 1
  • 7
  • 26