Your relations are correct, the controller has flaws.
Problem is that you have a field called champion and the relation has the same name
The only thing I would change is relation name skin
-> skins
to make it verbose.
To make what you need do this:
// Champion model
public function skins()
{
return $this->hasMany('Skin');
}
// controller
$champions = Champion::with('skins')->get(); // with() means eager loading to avoid n+1 issue
@foreach($champions as $champion)
{{ $champion->id }}
@foreach($champion->skins as $skin)
<div> {{ $skin->set }} </div> // or whatever you like here
@endforeach
@endforeach
Now the controller that doesn't work:
$skin = Skin::all();
foreach ($skin as $s) {
echo $s->champion->champion; // $s->champion is a field on skins table
echo $s->champion; // outputs this field value
}
In this situation you can do this (but you'd rather not, rename field or relation instead):
echo $s->champion()->first()->id; // fetch related model and output its property