Closed nigelatdas closed 2 years ago
Also.. is there any downside to using hasOneThrough? different behaviour on delete?
There's no downside (the package is older than HasOneThrough
).
This relationship would work (Laravel tries to use user_datum_id
by default):
public function users()
{
return $this->belongsToThrough(User::class, UserData::class, null, '', [UserData::class => 'user_data_id']);
}
LOL... that makes so much sense! Perfect
On Tue, 8 Feb 2022 at 06:15, Jonas Staudenmeir @.***> wrote:
Also.. is there any downside to using hasOneThrough? different behaviour on delete?
There's no downside (the package is older than HasOneThrough).
This relationship would work (Laravel tries to use user_datum_id by default):
public function users() { return $this->belongsToThrough(User::class, UserData::class, null, '', [UserData::class => 'user_data_id']); }
— Reply to this email directly, view it on GitHub https://github.com/staudenmeir/belongs-to-through/issues/67#issuecomment-1031823589, or unsubscribe https://github.com/notifications/unsubscribe-auth/AV3WT6GEZVQBFCVY7WPJBXTU2AK3VANCNFSM5NW7BXSQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
We have a relationship Report -> UserData -> User with keys like this:
Report has a method as follows:
If I use
hasOneThrough
, when the query is evaluated:and I add a watch on
$items[0]->user
it evaluates to a user object.When I use
belongsToThrough
it evaluates tonull
.Any thoughts? Also.. is there any downside to using
hasOneThrough
? different behaviour on delete?Cheers Nigel