laravel collection contains

Solutions on MaxInterview for laravel collection contains by the best coders in the world

showing results for - "laravel collection contains"
Agustín
20 Feb 2019
1$collection = collect(['name' => 'Desk', 'price' => 100]);
2
3$collection->contains('Desk');
4
5// true
6
7$collection->contains('New York');
8
9// false
Mía
17 Jan 2020
1$collection = collect(['account_id' => 1, 'product' => 'Desk']);
2
3$collection->has('product');
4
5// true
Alex
03 Sep 2017
1$users->contains(1);
2
3$users->contains(User::find(1));
Emma
22 Apr 2020
1$collection = collect([1, 2, 3, 4, 5]);
2
3$collection->contains(function ($value, $key) {
4    return $value > 5;
5});
6
7// false