Answer the question
In order to leave comments, you need to log in
How to convert to readable json stdObject with nested objects?
Hello!
class UserAuthDto
{
public function __construct(
private UserDto $user,
private ApiTokenDto $auth,
)
{
}
}
dd(json_encode((array)$userAuth));
Answer the question
In order to leave comments, you need to log in
Not automatically. Implement the JsonSerializable interface in your class , whose jsonSerialize method will return the data to be serialized to JSON.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question