Is there a way to apply lazy to json() data? #250
-
I use the laravel-data library to create DTO objects from JSON data. I want to convert a part of Below is an example code (doesn't work). return DataDto::from(Http::get('some-url')->json()); class DataDto extends Data
{
public function __construct(
public readonly Lazy|ChildDto $data,
public readonly VersionDto $version,
) {}
public static function fromModel(array $json): self
{
return new self(
Lazy::create(fn () => ChildDto::from($json['data']),
VersionDto::from($data['version']),
);
}
} Thanks for reading. 🙏 |
Beta Was this translation helpful? Give feedback.
Answered by
rubenvanassche
Nov 16, 2022
Replies: 1 comment 1 reply
-
Hi @binbyz, This code looks correct, what's the type and contents of |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
eyedroot
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @binbyz,
This code looks correct, what's the type and contents of
Http::get('some-url')->json()
? is thefromModel
method triggered when you run this code (you can check this with a dd or ray).