What is the difference between BelongsTo And HasOne in Laravel

后端 未结 5 452
被撕碎了的回忆
被撕碎了的回忆 2020-12-23 16:19

Can any body tell me what is the main difference between
the BelongsTo and HasOne relationship in eloquent.

5条回答
  •  天命终不由人
    2020-12-23 17:13

    One-to-one relationship: You, as a User, can have one (hasOne) Profile. And of course the inverse also applies. Profile (belongsTo) a User. A user can't have more than one profile and a profile can't belong to multiple users.

提交回复
热议问题