vendredi 15 janvier 2016

Laravel hasMany relation on multiple columns

I'm trying to setup Laravel relations on an already existing database which I'm unable to change.

In this database there is a table named Teams with columns:

  • Teamleader_1
  • Teamleader_2

Furthermore there's a table named Users with a column:

  • User_id

The relation between these tables is as follows: Users.User_id = Teams.Teamleader_1 OR Users.User_id = Teams.Teamleader 2

How can I setup a hasMany relationship between Users and Teams on both teamleader columns?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire