where('status', 'accepted') ->whereDate('date', '<', $today) ->update([ 'status' => 'cancelled', ]); // Agendamentos pendentes cuja data já passou. Schedule::query() ->where('status', 'pending') ->whereDate('date', '<', $today) ->update([ 'status' => 'cancelled', ]); // 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', ]); } }