Answers for "laravel collection intersect"

PHP
0

laravel collection intersect

use App\Models\User;

$users = $users->intersect(User::whereIn('id', [1, 2, 3])->get());
Posted by: Guest on December-01-2020
0

laravel collection intersect

$collection = collect(['Desk', 'Sofa', 'Chair']);

$intersect = $collection->intersect(['Desk', 'Chair', 'Bookcase']);

$intersect->all();

// [0 => 'Desk', 2 => 'Chair']
Posted by: Guest on July-24-2021
0

laravel collection intersectKey

$collection = collect([
    'serial' => 'UX301', 'type' => 'screen', 'year' => 2009
]);

$intersect = $collection->intersectKey([
    'reference' => 'UX404', 'type' => 'tab', 'year' => 2011
]);

$intersect->all();

// ['type' => 'screen', 'year' => 2009]
Posted by: Guest on July-24-2021

Browse Popular Code Answers by Language