Skip to content

Commit

Permalink
fix explanation of automatic foreign key detection
Browse files Browse the repository at this point in the history
  • Loading branch information
introwit authored Jul 19, 2018
1 parent 2b70ebd commit 8144d2e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion eloquent-relationships.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ Once the relationship has been defined, we can retrieve the `Post` model for a `

echo $comment->post->title;

In the example above, Eloquent will try to match the `post_id` from the `Comment` model to an `id` on the `Post` model. Eloquent determines the default foreign key name by examining the name of the relationship method and suffixing the method name with `_id`. However, if the foreign key on the `Comment` model is not `post_id`, you may pass a custom key name as the second argument to the `belongsTo` method:
In the example above, Eloquent will try to match the `post_id` from the `Comment` model to an `id` on the `Post` model. Eloquent determines the default foreign key name by examining the name of the relationship method and suffixing the method name with a `_` followed by the name of the primary key column. However, if the foreign key on the `Comment` model is not `post_id`, you may pass a custom key name as the second argument to the `belongsTo` method:

/**
* Get the post that owns the comment.
Expand Down

0 comments on commit 8144d2e

Please sign in to comment.