staudenmeir / belongs-to-through

Laravel Eloquent BelongsToThrough relationships
MIT License
1.15k stars 88 forks source link

Implemention of BelongsToThrough::associate() method #81

Closed mrezauli closed 1 year ago

mrezauli commented 1 year ago

It would be best if Znck\Eloquent\Relations\BelongsToThrough::associate() method is implemented just like Laravel's native BelongsTo::associate()

staudenmeir commented 1 year ago

Hi @mrezauli, The issue is that an associate() method is not really possible for BelongsToThrough relationships. Consider the example from the README: https://github.com/staudenmeir/belongs-to-through#usage

You can't call $post->country()->associate($country) because Post and Country aren't related directly – only through User. So you can only associate a User to a Post, but that's just a normal BelongsTo relationship.

Do you know what I mean?