Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

201
Vistas
Passing a route parameter / form data through all controller functions

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:

  • Model DB1entries - DB1 - entries_table
  • Model DB2entries - DB2 - entries_table
  • Model DB3entries - DB3 - entries_table

So 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.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

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

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda