I want to fetch only 4 rows from my database's table.
$data=table::all();
Returns all data/rows from my table. How can I get only 4 rows instead of all?
Thanks
CodePudding user response:
Try $data=table::take(4);
that will only retrieve the 4 first records.
You also have the limit()
method. See details in the Laravel Limit & Offset docs.