Hi. I'm trying to write a json api. I want to send all the children, grandchildren and so on, along with the parent record.
If I use the following code the json output only contains the parent (Customer) record, but I want to include all the customer's orders, all the products on the order, and all the parts needed to make the product.
// Customer hasMany Order // Order hasMany Product // Product hasMany Part $customer = Customer::findFirst($id); echo json_encode($customer); // Only outputs the parent (Customer) record
Is there an easy way to get all the children many levels deep? (without manually building arrays with foreach loops).