Answers for "laravel collection diff"

PHP
0

laravel collection diff

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

$diff = $collection->diff([2, 4, 6, 8]);

$diff->all();

// [1, 3, 5]
Posted by: Guest on April-18-2021
0

laravel collection diff

use App\Models\User;

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

laravel collection diffKeys

$collection = collect([
    'one' => 10,
    'two' => 20,
    'three' => 30,
    'four' => 40,
    'five' => 50,
]);

$diff = $collection->diffKeys([
    'two' => 2,
    'four' => 4,
    'six' => 6,
    'eight' => 8,
]);

$diff->all();

// ['one' => 10, 'three' => 30, 'five' => 50]
Posted by: Guest on July-24-2021

Browse Popular Code Answers by Language