Have you created relations for your models?
Merging two models (with a prefix)
Hello everyone! Hope you're having a fantastic day.
Well, i'm stuck with my code. I have two models: one called Customer.php and another called Order.php
The customers can make orders in my application (like an ecommerce).
The problem is: In my Order.php I have to replicate the informations of Customer, because if someone removes the customer from my database, I need to still see the informations of customer in my order. So in my migrations I have something like this, let's simplify:
Customer migration: id, code, name, document Order migration: id, code, customer_id, customer_name, customer_document
When I create an order, I select a customer from a select box, which returns me only the customer ID, so in my controller I fetch this ID and get the customer.
I want to "merge" the customer fetched into the orders model, but I have the "customer_" prefix.
You know a better way to do that?
Thanks for all! Have a nice day!
Please or to participate in this conversation.