Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. private function getEventsListFromBookings($filter_location, $filter_property)
  2. {
  3. $events = array();
  4. if(isset($filter_location) && is_numeric($filter_location))
  5. {
  6. if(isset($filter_property) && is_numeric($filter_property))
  7. {
  8. $bookings = Booking::
  9. where('property_id','=',$filter_property)
  10. ->where('is_payed','=' , 1) //booking which are confirmed
  11. ->where('arrival' ,'>' , (Carbon::today())->subMonths(3))
  12. ->get();
  13. }
  14. else
  15. {
  16. $properties = Property::where('location_id', '=' ,$filter_location)->pluck('id')->toArray();;
  17.  
  18. $bookings = Booking::
  19. where('arrival' ,'>' , (Carbon::today())->subMonths(3))
  20. ->where('is_payed','=' , 1)
  21. ->whereIn('property_id',$properties)
  22. ->get();
  23. }
  24. }
  25. else
  26. {
  27. //This case may not be never used. Created if a filter to have bookings for all locations is created
  28. $bookings = Booking::
  29. where('arrival' ,'>' , (Carbon::today())->subMonths(3))
  30. ->where('is_payed' , '=' , 1)
  31. ->get();
  32. }
  33.  
  34. foreach ($bookings as $booking) {
  35. $guest = Guest::where('booking_id','=',$booking->id)->get()->first();
  36.  
  37. $BookingServices = BookingService::where('booking_id', '=', $booking->id);
  38. $AttachedService = "";
  39. foreach ($BookingServices as $BookingService) {
  40. $AttachedService = $AttachedService .''. Service::where('id', '=', $BookingService->id)->name .', ';
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement