/** * A cron that will delete all reservations 24hours to the trip departure date */ public function clean() { $start = Carbon::today()->startOfDay(); $end = Carbon::today()->endOfDay(); $trip_ids = Trip::whereBetween('departure_date', [$start, $end])->lists('id')->toArray(); $cleaned = Booking::where('status', 'reserved')->whereIn('trip_id', $trip_ids)->delete(); return $cleaned; }