Let's say we have three models, a User, a Products and an Order model. All of these models are related to the Account model in the definitions like so:
'account_id' => 'factory|Account'
Let's assume, the account model has a unique field "hash".
Let's say, products and orders have also a defined relation.
The problem:
If I create an order with multiple products I will run into an issue with the unique key on the account model. Since the same account model will be created into the database and applied to all of the products and the order.
Let's say we have three models, a
User
, aProducts
and anOrder
model. All of these models are related to theAccount
model in the definitions like so:'account_id' => 'factory|Account'
Let's assume, the account model has a unique field "hash". Let's say, products and orders have also a defined relation.
The problem: If I create an order with multiple products I will run into an issue with the unique key on the account model. Since the same account model will be created into the database and applied to all of the products and the order.
Is there a way to work around this issue?