startOfDay()->addDay(); $tomorrow_end = Carbon::now()->endOfDay()->addDay(); $appointments = DB::table('patient_appointments') ->whereBetween('appointment_date', [$tomorrow_start, $tomorrow_end]) ->get(); foreach ($appointments as $appointment) { if (is_sms_enabled()) { // send sms alert to the patient $sms = "This is a reminder that your appointment at " . get_name(1, 'id', 'name', 'hospital_information') . " is scheduled for tomorrow the " . streamline_date($appointment->appointment_date) . " at " . $appointment->appointment_time; (new SMSController)->send_appointments_alert($appointment->patient_id, $sms); } } } }