简体   繁体   中英

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...

As Per @maki10 The working Solution Is

public function teams() {
      return $this->hasManyThrough(
         'App\model\Team',
         'App\model\MatchTeam',
         'match_id',
         'id',
         'id',
         'team_id'
      );
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM