Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $listings = Listing::has('photos')->get();
- // fetch all the listings, eagerly loading the photos relationship
- $listings = Listing::with('photos')->get();
- foreach ($listings as $key => $listing)
- {
- // if the listing has photos, remove it from the collection
- if (count($listing->photos) != 0)
- {
- unset($listings[$key]);
- }
- }
- $users = $users->filter(function($user)
- {
- if($user->isAdmin())
- {
- return $user;
- }
- });
- $listings = $listings->filter(function($listing)
- {
- // Keep listings with no photos
- if (count($listing->photos) == 0)
- {
- return $listing;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement