Closed baukevdw closed 4 years ago
This extra parameter only allows for a different foreign key. What about specifying a different table name? The junction table cannot possibly be configured with extra parameter (not unless you litter the belongsToMany API with all possible parameters).
Instead I think you should be able to pass a callable as second argument to the has-/belongsTo-One/Many functions that allows you to interact with a factory for building these relations. To avoid the need for references to be created using this callable, a reference factory might then be stored inside the relation.
If you need to reference for example an user class from an order class multiple times:
This causes two problems:
The current solution to these issues is to initialize the relations manually which is far from ideal.
Something like this: