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

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -