Taking the following database example of services, and a subset of services, e.g. hosting services, I have the following dilemma:
I create a main table, called 'services', and a model Service.
This table contains settings that are common to all services and those are:
*id
*description
*monthly_price
I create another table called 'hosting_services' and a model HostingService.
The reason why I create another table is because I would like to add other types of services in the future as well, for example GardeningService.
In the HostingService, I have some specific fields, e.g.:
*domain
*disk_space
*disk_space_used
How can I gracefully handle this in Laravel?
My research indicates multiple solutions but nothing solid. I also note from research here https://laravel-news.com/2016-survey/ that some people in the community are requesting "Better model inheritance support".
-
Stack Overflow post describing Polymorphic Relations (PR) versus Single Table Inheritance (STI)
https://stackoverflow.com/questions/23973850/model-inheritance-in-laravel#
-
Example extending abstract classes.
-
Link to Dauce's extension to Eloquent, noting issues with this extension.
https://github.com/ThibaudDauce/EloquentInheritanceStorage
I'm really completely lost here and just need some pointers if this is do-able or if I should do normal belongsTo and hasMany instead which makes data summarizing and editing a lot more difficult.