I'm having a problem understanding how I can grab use a specific title to retrieve all models that have won that specific title. Each title can be won by different types of models so I wanted to make sure that I apply which model type it is.
I think the title of this thread should be more along the lines of "Having trouble structuring the database for my app"... or something... with a quick summary/story/description of what you want it to do and this attempt at the structure ☝🏼
anywho, I'll be back around... I have to step out for a bit.
class Title extends Model
{
public function wresters()
{
return $this->morphedByMany(Wrestler::class, 'championable');
}
public function tagTeams()
{
return $this->morphedByMany(TagTeam::class, 'championable');
}
public function allWinners()
{
return $this->tagTeams->merge($this->wrestlers);
}
}
And that allWinners method is to get all relevant model objects.