HasOne/MorphOne loads any fields/relationships when included. Intended or bug? #5073
-
I have a user, who has an address that has logs (user → morphOne address → hasMany logs). Within the user details page, address logs are being show and there's no way to hide them. The same behaviour occurs for fields in general: They cannot be hidden easily (as far as I know). This blows up detail pages heavily. I don’t know, whether this behaviour is intended or a bug?! If it’s intended, I’d like to suggest a new method to hide a relationship on “include”, such as UserAddressExample with relations |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Yes this is the intended behavior at the moment. However, you can prevent it by using the following: // before
HasMany::make('Logs'),
// after
$this->mergeWhen(
$request->isPresentationRequest() && ! $request->viaRelationship(),
fn () => [
HasMany::make('Logs'),
]
), |
Beta Was this translation helpful? Give feedback.

Yes this is the intended behavior at the moment. However, you can prevent it by using the following: