whereIn('status', ['accepted', 'pending']) ->whereDate('date', '<', $today) ->update([ 'status' => 'cancelled', 'cancel_text' => 'Agendamento expirado', ]); // Agendamentos pendentes de hoje cujo horário já terminou. Schedule::query() ->where('status', 'pending') ->whereDate('date', $today) ->whereNotNull('end_time') ->whereRaw("CAST(end_time AS time) < ?", [$now->format('H:i:s')]) ->update([ 'status' => 'cancelled', 'cancel_text' => 'Agendamento expirado', ]); } }