Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!