What is the difference between BelongsTo And HasOne in Laravel
问题 Can any body tell me what is the main difference between the BelongsTo and HasOne relationship in eloquent . 回答1: BelongsTo is a inverse of HasOne. We can define the inverse of a hasOne relationship using the belongsTo method. Take simple example with User and Phone models. I'm giving hasOne relation from User to Phone. class User extends Model { /** * Get the phone record associated with the user. */ public function phone() { return $this->hasOne('App\Phone'); } } Using this relation, I'm