I think we are having some communication problems
Let me explain my situation more thorougly:
First, this is the only problem in my 40+ model application. The other models are all saving without problem.
I’ve got the situation where I have contractnumbers. Each contract number can have multiple sub-contracts. This is a one to many relationship.
At the same time I have a many to many relationship between the same models. A subcontract gets an additional discount when used in combination with one (or more contracts). So I have the following tables:
1. contract
- id
- contract name
2. subcontract
- id
- contract_id
- etc.
3. contract_subcontract
- contract_id
- subcontract_id
- percentage
Now, I defined the relationships as you suggested in your reply at the bottom of page 40.
So now I try to add some contracts to a subcontract, using the table contract_subcontract.
How do I save such a contract? Normally you would do something like $subcontract->save(array($contract->all)) (provided all contracts already have an id), but in my case the system does not know which one to fill:
contract_id in the subcontract model, or add a row to the contract_subcontract table. In my situation it just takes the contract_id in the subcontract table/model.
I hope I explained myself well enough this time 