Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private function getEventsListFromBookings($filter_location, $filter_property)
- {
- $events = array();
- if(isset($filter_location) && is_numeric($filter_location))
- {
- if(isset($filter_property) && is_numeric($filter_property))
- {
- $bookings = Booking::
- where('property_id','=',$filter_property)
- ->where('is_payed','=' , 1) //booking which are confirmed
- ->where('arrival' ,'>' , (Carbon::today())->subMonths(3))
- ->get();
- }
- else
- {
- $properties = Property::where('location_id', '=' ,$filter_location)->pluck('id')->toArray();;
- $bookings = Booking::
- where('arrival' ,'>' , (Carbon::today())->subMonths(3))
- ->where('is_payed','=' , 1)
- ->whereIn('property_id',$properties)
- ->get();
- }
- }
- else
- {
- //This case may not be never used. Created if a filter to have bookings for all locations is created
- $bookings = Booking::
- where('arrival' ,'>' , (Carbon::today())->subMonths(3))
- ->where('is_payed' , '=' , 1)
- ->get();
- }
- foreach ($bookings as $booking) {
- $guest = Guest::where('booking_id','=',$booking->id)->get()->first();
- $BookingServices = BookingService::where('booking_id', '=', $booking->id);
- $AttachedService = "";
- foreach ($BookingServices as $BookingService) {
- $AttachedService = $AttachedService .''. Service::where('id', '=', $BookingService->id)->name .', ';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement