Laravel Eloquent how to get the second or third record? -
i have order , product models.
"order" hasmany product (and product belongsto order)...
let's want display 3 products of order, how ?
know first retrieved $order->products->first()... how retrieve second , third product?
i tried $order->products->find(1) "1" represents id of product... don't want know...
i found solution, correct syntax:
$order->products->get(0)->name; return first record $order->products->get(1)->name; return second record $order->products->get(2)->name; return third record and on...
Comments
Post a Comment