Skip to content

Commit

Permalink
Merge pull request #4386 from introwit/patch-2
Browse files Browse the repository at this point in the history
Fix explanation of automatic foreign key detection in 'One to many' relationship block
  • Loading branch information
taylorotwell authored Jul 20, 2018
2 parents f79ee4a + 8144d2e commit ba31b1c
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 ba31b1c

Please sign in to comment.