How does/would the database design look like?
HasMany through a polymorphic instance
I'm currently dealing with some kind of issue in my head. I want to achieve that a Customer may create many payment methods in order to pay an invoice.
For example I want the customer to be able to create multiple Stripe- and multiple PayPal-Subscriptions. I'm currently stuck with the database design as I want to do something like Customer->paymentMethods and Eloquent shall return me a collection of all the StripeSubscription and PayPalSubscription models. I thought I could achieve this using polymorphic relationships but after watching the videos about it I'm kinda confused if this is the right way to do it.
It's something like a "a customer can have many $model through the payment_methods-table". Maybe you could give me some kind of head's up in this case.
There is no way to define a relationship that returns all the different types at once.
You can define multiple MorphedByMany relationships and merge them with an accessor: https://stackoverflow.com/a/52877724/4848587
Please or to participate in this conversation.