$next = $collection->where('product_id'>'342'->where('customer_id'>'62'));
Mar 27, 2018
4
Level 7
Search and skip to Next item in collection
I have a collection below, which I would like to search and get the contents of the next items https://laravel.com/docs/5.6/collections#method-where
where() function would find for example.
$collection->where('product_id', '342')->where('customer_id', '62')
How can I get the contents of the next one? which is in this case +"product_id": 456 +"customer_id": 933
When I run the code above I got the key. Maybe if I can reach it and increment it 1 and if there is a way like $collection->get(x) it would solve my problem I suppose
Collection {#630 ▼
#items: array:14 [▼
0 => {#638 ▼
+"product_id": 378
+"customer_id": 936
}
1 => {#635 ▼
+"product_id": 342
+"customer_id": 62
}
2 => {#597 ▼
+"product_id": 456
+"customer_id": 933
}
3 => {#632 ▼
+"product_id": 450
+"customer_id": 935
}
4 => {#633 ▼
+"product_id": 435
+"customer_id": 934
}
]
}
Please or to participate in this conversation.