Skip to content
Advertisement

connect laravel application with database based on the url

hi im using laravel 6 project i want to connect my application to database based on the url like this schema

JavaScript

and i did this steps in my config/config.php

JavaScript

i did this code to use the $application_path in controllers like this code

JavaScript

and in my AppServiceProvider.php i did this code

JavaScript

to use $application_path inside the blade like this

JavaScript

and in my config/database.php i did this code

JavaScript

and i have databases called

JavaScript

so what im trying is when im visit www.mywebsite.com/project1 connect me with database project1 and use the folder companys/project1 as the public folder and do the same for other links project2 project3 ect .. now when i upload the files to the cpanel everything is working till it redirect me to the login url with loading and un loaded loading blank page .. any help here thanks a lot

Advertisement

Answer

I think this answer in the other question would help you out!: https://stackoverflow.com/a/31847198/8219427

If not, then there is official Laravel documentation.: https://laravel.com/docs/database#using-multiple-database-connections

Ps.: Use the framework provided options, example get the uri from request object! https://laravel.com/docs/requests example:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement