I'm trying to figure out how to get nested JSON output using the toJSON() function of fActiveRecord. Here's what I'm doing:
$user = new User(array('email' => [string from POST])); // Create a singular User object $user->buildAddresses(); // Retrieve *-to-many Addresses for the User $user->buildPhoneNumbers(); // Retrieve *-to-many PhoneNumbers for the User
echo $user->toJSON(); // Convert and output the user as JSON
When I do var_dump($user), I can see the whole object including the Addresses and PhoneNumbers as nested parts of the User object. However, $user->toJSON() only returns the main User part of the object.
How do I include Addresses and PhoneNumbers as nested JSON in my output?