Skip to content
Advertisement

Laravel Dynamic DB Relation

I didn’t find any solution so i am asking it here..

Match.php 
id , teams           name
1    5,6(string)   kkr vs mi
Team.php 
id  name 
5   kkr
6   mi

The id of Team is related with teams in Match ,for this the solution is easy.. but The Problem is that one Match can have 3/4+ no of teams So i have to make it dynamic …

Advertisement

Answer

As Per @maki10 The working Solution Is

public function teams() {
      return $this->hasManyThrough(
         'AppmodelTeam',
         'AppmodelMatchTeam',
         'match_id',
         'id',
         'id',
         'team_id'
      );
    }
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement