You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|Model A relation |`hasOne`|`hasMany`|`morhpMany` (all) |`belongsToMany`|`morphToMany` (all) |
|Model B relation |`belongsTo`|`belongsTo`|`morphTo`|`belongsToMany`|`morphToMany`|
|Set relation on Model A|`save(B)`|`saveMany([B1, B2])`<br>`save(B)`|`saveMany([B1, B2])`<br>`save(B)`|`attach([B1, B2])`<br>`sync([B1, B2])`|`saveMany([B1, B2])`<br>`save(B)`|
|Set relation on Model B|`associate(A)->save()`|`associate(A)->save()`|`associate(A)->save()`|`attach([A1, A2])`<br>`sync([A1, A2])`|`attach([A1, A2])`<br>`sync([A1, A2])`|
|Foreign key holder |Model B table (`A_id`)|Model B table (`A_id`) |Model B table (`A_id`, `A_type`) |Pivot table (`A_id`, `B_id`) |Pivot table (`A_id`, `A_type`, `B_id`)|
## One to One Relationship
##### Demo details:
In this demo we have 2 models (**Owner** and **Car**), and 2 tables (**owners** and **cars**).
avataru
revised
this gist Oct 5, 2017.
1 changed file
with
372 additions
and
8 deletions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters