Home > Mobile >  Relationship with attribute laravel 8
Relationship with attribute laravel 8

Time:10-25

I want make relationship with attribute but i dont understand how to do that with laravel ORM Eloquent, can somebody help me? Thanks in advance

relational diagram image

CodePudding user response:

If I'm not mistaken, you want to have a many-to-many relationship between your Mahasiswa and Team. Basically, it means that you have many teams, and each teams has its own members, so does members, each member can have teams. So you will need an intermediate/a pivot table between those two, for ex. mahasiswa_team. Then, inside mahasiswa_team table, you could add the role column to define each member's role.

For many-to-many relationship inside Laravel 8, you can see the documentation here.

If many-to-many relationship is not correct, then my last guess is you want the one-to-many relationship between Team and Mahasiswa. In that case, you want to move your role column to the Mahasiswa table. For one-to-many relationship, you can see the documentation here.

CodePudding user response:

From here you can get all the necessary information.

  • Related