belongsTo would indicate the foreign key on the table for that model. hasMany/hasOne indicates the other model's table references this model's id.
For example, a post table might have fields like this:
id
title
body
author_id (foreign key referencing user id)
and comments like this:
id
post_id (foreign key referencing post)
comment
author_id (foreign key referencing user id)
Models would look like this:
Post:
public function comments() {
return $this->hasMany('App\Comment');
}
public function author() {
return $this->belongsTo('App\User', 'author_id');
}
because posts have (potentially) many comments, and belong to/are owned by a specific user. The user's id is stored on the post table, comment ids are not.
Comment:
public function post() {
// because we used post_id for the foreign key we don't need to specify it
// as that is the assumed default: [snakeCased model name]_id
return $this->belongsTo('App\Post');
}
public function author() {
return $this->belongsTo('App\User', 'author_id');
}
because an individual comment belongs to only one post, and is owned by only one user, those foreign keys are stored in the comment table.
Finally, Users can have many posts and many comments, so on the User model:
public function posts() {
// User's id is referenced in the post table as 'author id' so we must specify that here.
return $this->hasMany('App\Post', 'author_id');
}
public function comments() {
// Again, user's id is referenced in the comments table as 'author id' so we specify it here.
return $this->hasMany('App\Comment', 'author_id');
}