You shouldn't store any of the features in the database and control behaviour of the app with it. Have different implementations do that through polymorphism.
Best Practice Advice: Embed API implementation inside Model or elsewhere?
I'm creating a Laravel application in which each Client (model) can specify API connections to zero or more CRMs (of various species). For instance, a Client might have zero or more ActiveCampaign accounts, zero or more MailChimp accounts, zero or more Convert Kit accounts, etc.
I'll add new CRMs to the application over time.
Because both the API implementation and supported features (i.e. lists, tags, fields, notes, etc.) for each CRM can differ wildly, it makes intuitive sense to use a distinct Eloquent Model for each CRM. (NB: Cramming them all into a single model seems like a bad idea since I'll inevitably have to add fields to support new CRMs in the future. Tell me if you disagree.)
I've defined an abstract Interface with public methods to perform common CRM function... createContact(), addContactToList(), addTagToContact(), etc.
My question is this:
If each CRM is represented by its own Model, does it make sense to have the Model implement the interface (and related business logic)?
Or... should the implementation be handled by a distinct class that keeps the Model "clean" (i.e. separate from the business logic)?
Many thanks.
Please or to participate in this conversation.