Answers for "laravel is in collection"

PHP
1

laravel check if item is in collection

// You may also pass a key / value pair to the contains method,
// which will determine if the given pair exists in the collection:

$collection = collect([
    ['product' => 'Desk', 'price' => 200],
    ['product' => 'Chair', 'price' => 100],
]);

$collection->contains('product', 'Bookcase');
// false
Posted by: Guest on January-14-2021
4

collection laravel filter

$collection = collect([1, 2, 3, 4]);

$filtered = $collection->filter(function ($value, $key) {
    return $value > 2;
});

$filtered->all();

// [3, 4]
Posted by: Guest on November-17-2020
0

laravel check if item is in collection

// you may pass a string to the contains method to determine whether
// the collection contains a given item value:

$collection = collect(['name' => 'Desk', 'price' => 100]);

$collection->contains('Desk');
// true

$collection->contains('New York');
// false
Posted by: Guest on January-14-2021
0

pluck laravel

$name = DB::table('users')->where('name', 'John')->pluck('name');
Posted by: Guest on January-18-2021
0

laravel pluck

$users = Users::pluck('name','email');
dd($users);
Posted by: Guest on October-05-2020

Code answers related to "laravel is in collection"

Browse Popular Code Answers by Language