Eager loading category data from a Matrix block How might I eager load category data in a plugin? I can't seem to figure out why I can't access a category in this way:

locationOffers is a matrix block name, category is the handle of a related category field inside of the matrix block

// this adds an empty category array to each related offer
$relatedOffers = $entry-&gt;locationOffers-&gt;with(['category'])-&gt;all(); 
print_R($relatedOffers-&gt;category); // is empty

// this regular way works, where I can access category-&gt;title, and more, 
// but is not eager loaded
$relatedOffers = $entry-&gt;locationOffers-&gt;all();
Apologies, I misread the question the first time around.

When eager loading via a matrix block, you need to provide a blocktype as well as the field name.

See: https://docs.craftcms.com/v3/dev/eager-loading-elements.html#eager-loading-elements-related-to-matrix-blocks for more details