Thank you so much, @silencebringer! With a few tweaks to your answer, I was able to make it work the way I need it to.
First, I noticed that your ->sortKeys() was missing the parentheses at the end. That tripped me up for a moment. However, I don't really need to do the sorting in Laravel since I'm doing so in the DBMS, which I've been told is more performant.
$armorSets = ArmorSet::with([
"armors.resources" => function ($query) {
$query->orderBy("tier", "asc");
},
])->get();
return view("index", compact("armorSets"));
Then, rather than plucking from a collection, I wanted the armor_resource.quantity_needed field to be next to each resource needed. Thus, one more nested @foreach was necessary, leaving me with quite the nested loops:
<div>
@foreach($armorSets as $armorSet)
<div>
<h2>{{ $armorSet->name }}</h2>
@foreach($armorSet->armors as $armor)
<h3>{{ $armor->name }}</h3>
@if($armor->upgradable)
@foreach($armor->resources->groupBy(fn($resource) => $resource->pivot->tier) as $tierNum => $resources)
<p>Tier {{ $tierNum }}:</p>
@foreach($resources as $resource)
<p>{{ $resource->pivot->quantity_needed }} {{ $resource->name }}</p>
@endforeach
@endforeach
@endif
@endforeach
</div>
@endforeach
</div>
I also adjusted a couple of variable names there for clarity. In the end, that gives me exactly what I was looking for:
Hylian Set
Hylian Hood
Tier 1:
5 Bokoblin Horn
Tier 2:
5 Bokoblin Fang
8 Bokoblin Horn
Tier 3:
10 Bokoblin Fang
5 Bokoblin Guts
Tier 4:
15 Bokoblin Guts
30 Amber
Obviously, I have no styling yet; I'm just working out the logic and Eloquent queries first. But this gives me a great start to my new project. Thank you again!