-
-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Livewire - unable to call lazy data #257
Comments
This works: $user->email->resolve() However I don't think this is correct? Maybe a loader for Livewire should be added: https://github.com/spatie/laravel-data/blob/main/docs/advanced-usage/use-with-inertia.md |
Hi @francoism90, This is correct behavior, calling include on a property will only affect when you're transforming a data class (toArray, toResponse, toJson, ....). Inertia works a bit different then LiveWire since it will internally call Another solution could be to make lazy |
@rubenvanassche Thanks for your reply! I don't fully understand the Would you recommend to use I didn't test Thanks! |
Yeah!
I would expect not, since the lazy prop will be used. |
@rubenvanassche Sorry for bumping this, but could you please tell me how it should work with Htmlable? I've found this post: https://itnext.io/laravel-the-fantastic-4-interfaces-renderable-6dbdd3c5e539 If I understand correctly, I need to check if the property is a Lazy instance and use resolve(), or when it's already resolved, return without this method. This is what I'm doing now:
|
I would create a new Lazy class underneath the package Lazy class, extend HtmlAble which has a render method if I'm not mistaken and then use the code you've provided above. Then in your data classes you would use your own implemented Lazy class instead of the default laravel-data one. |
@rubenvanassche Thanks for your input! I'll try to extend the Lazy class with HtmlAble and see how this works out for us. :) |
It doesn't seem the
include
is being parsed/loaded.Result:
My blade simple uses:
{{ $user->email }}
If more info is needed, please let me know!
Thanks
The text was updated successfully, but these errors were encountered: