Hi guys,
I guess you have mistakes in your github example.
Check those two models.
belongsTo
should be in pair with hasOne
in the other model, right?
Best regards,
Vaclav
Hi guys,
I guess you have mistakes in your github example.
Check those two models.
belongsTo
should be in pair with hasOne
in the other model, right?
Best regards,
Vaclav
Hello @Vaclav,
Thanks for the feedback. It’s not a proper error since using only belongsTo works. Both give the same results.
Order.belongsTo(Product); // `productId` will be added on Order / Source model
Product.hasOne(Order) // `productId` will be added on Order / Target model
I personally prefer using belongsTo in pair with hasOne since it’s cleaner and reflect the model definition on both models.
Kind regards,
Morgan
Hi @morganperre,
thank you for the explanation. I though it is compulsory to use that on both models.
Best regards,
Vaclav