if you have 50 columns in a single table, probably you need to redesign your database schema mate.
https://laravel.com/docs/master/eloquent-relationships#polymorphic-relationships
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I have a customer table, which carries around 50 columns in the database. The customer qualifies for different tiers based on certain criteria, like Tier 1, Tier 2, and so on. Each tier has its own set of properties.
In database, the logical design is that I have one main table which carries all new (tier0) customers. For tier 1, I create a new table called tier1, put a foreign key/identifier to customer table, and rest of the columns belong to tier 1 variables. Similarly, tier 2 table also has one foreign key to the main table, and rest its own variables. Note that the variables (i.e. columns) of tiers are not the same.
Now, I want to make multiple models of customers based on the tiers in which they fall. Like, one model for tier1 customer, a different model for tier 2 customer, another model for tier 3 customer, and so on. The model should be able to access all the info of the customer from the main table.
The issue: The model of tier 1 expects all customer attributes to be in the tier 1 table. In other words, it asks me to copy the whole main table into tier 1 table, and then move on. Same is for tier 2 and tier 3 tables.
It does not seem logical to me: A framework addresses same type of optimization, over simple programming.
Please guide me about how to handle this situation, i.e. make multiple models on top of info spread in other than model tables.
Thanks, Saad
Please or to participate in this conversation.