Got a small problem I need help solving out, I'm using laravel version 8.
So I have 3 different databases which have the same tables, I made a model for each database.
So for reference:
DB1entries - DB1 - entries_tableDB2entries - DB2 - entries_tableDB3entries - DB3 - entries_tableSo when sending a request i want all requests get to the same controller but the database can be changed depending on the request DB selected, can be with a param on the route.
for example:
/db1/store would go to EntriesController and create the entry in DB1
/db2/store would go to EntriesController and create the entry in DB2
but the "set" for the model wouldn't be the store function in EntriesController.
I just don't want to use the same function to set the model for each function inside the controller, I want to create it dynamically in the constructor or any other solution.
If that is how you want to define your routes then you could have /db1/store or /db2/store be a route parameter
https://laravel.com/docs/8.x/routing#route-parameters
which would look like /{db}/store