Reputation: 473
I have a collection of all doors, and a collection of doors that the current user has access to. How can I compare the two and remove from the all doors collection the doors the user already has access to?
$doors = Door::orderBy('name', 'asc')->get();
$users_doors = $user->doors;
Here are the two collections.
Upvotes: 0
Views: 1797
Reputation: 25906
Use Collection::diff()
:
$doorsWithAccess = $doors->diff($users_doors);
Upvotes: 3