Hi !
Thanks for your effort so far!
The Car is defined with: has_many Tires.
The Tire is defined with: has_one Car.
I create a car ($car) and then add a tire like this:
$tire = new Tire();
$tire->Title = "my tire";
$tire->URLSegment = "my-tire";
$tire->write();
$car->Tires()->add($tire);
In the database the Tire table as a column called CarID - wich relates the tire to a specific car. When firing the above code the column CarID gets updated with the correct CarID. So that part works out just fine.
Since its all Page types (extends Page) I would expect the new item (the tire) to end up as a children of the Car in the CMS. But since the ParentID in the SiteTree table for the tire row is 0 the new tire ends up in the root of the tree menu structure and not underneath the car as I would have expected.
My concern is now: Am I doing something wrong here or am I supposed to manage ParentID's myself? I know I could just set the ParentID when i create the Tire, but for most of the cases in a CMS I think it would make sense to have that implemented by default.
I hope this clears out my question.