Skip to content

Commit e75b04d

Browse files
committed
Merge branch 'phroggyy-patch-3'
2 parents 0995fbd + caed9e1 commit e75b04d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

eloquent-relationships.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,15 +368,19 @@ Now that we have examined the table structure for the relationship, let's define
368368

369369
The first argument passed to the `hasManyThrough` method is the name of the final model we wish to access, while the second argument is the name of the intermediate model.
370370

371-
Typical Eloquent foreign key conventions will be used when performing the relationship's queries. If you would like to customize the keys of the relationship, you may pass them as the third and fourth arguments to the `hasManyThrough` method. The third argument is the name of the foreign key on the intermediate model, the fourth argument is the name of the foreign key on the final model, and the fifth argument is the local key:
371+
Typical Eloquent foreign key conventions will be used when performing the relationship's queries. If you would like to customize the keys of the relationship, you may pass them as the third and fourth arguments to the `hasManyThrough` method. The third argument is the name of the foreign key on the intermediate model. The fourth argument is the name of the foreign key on the final model. The fifth argument is the local key, while the six argument is the local key of the intermediate model:
372372

373373
class Country extends Model
374374
{
375375
public function posts()
376376
{
377377
return $this->hasManyThrough(
378-
'App\Post', 'App\User',
379-
'country_id', 'user_id', 'id'
378+
'App\Post',
379+
'App\User',
380+
'country_id', // Foreign key on users table...
381+
'user_id', // Foreign key on posts table...
382+
'id', // Local key on countries table...
383+
'id' // Local key on users table...
380384
);
381385
}
382386
}

0 commit comments

Comments
 (0)