A friend treated me to a meal.

Literal

Friend [source-に] meal [object-を] treat-and [received favor-もらった].

おごる means to treat someone by paying for their food or drink. Wrapping it in ~てもらった frames the speaker as the grateful recipient of that generosity. ご飯 here means 'a meal' broadly, not specifically 'rice.'