I'm trying to implement some core classes for a project and I'm using models relationships. To help explain the problem lets suppose I have two models: Model and RelatedModel, where Model.Id relates to RelatedModel.Id. I declare a HasOne in the Model class passing 'Id', 'RelatedModel', 'Id'... so its expected that I use a "RelatedModel" field in the Model class to create the relation... something like:
$model = new Model(); $related = new RelatedModel(); $model->RelatedModel = $related; $model->save();
And that works just fine... But lets suppose I want to use a IDE autocomplete feature, or that I enforce oop as a rule of conduct. So I need to declare the 'RelatedModel' field in the Model class... But when I do that the $related is not send to the database, its ignored.
Is this supposed to happen? If so, how do I enforce oop when using model relationships?
Thanks in advance!