Replies: 1 comment
-
Hi @ahoiroman 👍 if I understand correctly Lazy::whenLoaded('location', $company, fn() => $company->location); for default data issue you could use eloquent-relationships#default-models According to Laravel Docs :
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I'd like to solve an issue. In my controller I am calling:
If a new Company does not have a location yet, the result is always
NULL
, although the relation is loaded.This can be explained by looking at the RelationalLazy. class:
Okay - so now I created a little workaround:
As you can see here, I am returning the
LocationData
if the location does exist - and if not I am returning a blueprint, as my Vue-frontend wants to work withcompany.location
.My question: Is there a more elegant way to solve this issue?
Beta Was this translation helpful? Give feedback.
All reactions