Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. $listings = Listing::has('photos')->get();
  2.  
  3. // fetch all the listings, eagerly loading the photos relationship
  4. $listings = Listing::with('photos')->get();
  5.  
  6. foreach ($listings as $key => $listing)
  7. {
  8. // if the listing has photos, remove it from the collection
  9. if (count($listing->photos) != 0)
  10. {
  11. unset($listings[$key]);
  12. }
  13. }
  14.  
  15. $users = $users->filter(function($user)
  16. {
  17. if($user->isAdmin())
  18. {
  19. return $user;
  20. }
  21. });
  22.  
  23. $listings = $listings->filter(function($listing)
  24. {
  25. // Keep listings with no photos
  26. if (count($listing->photos) == 0)
  27. {
  28. return $listing;
  29. }
  30. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement