A
A
alexh78542019-11-01 18:00:23
Laravel
alexh7854, 2019-11-01 18:00:23

How to connect to different sqlite databases in laravel depending on subdomain?

Hello.
Tell me how to implement such functionality:
There is a project on laravel, sqlite database, multilingual site, language versions on subdomains. Each language version has its own database - db_ru.sqlite, db_en.sqlite, etc.
The database name contains a subdomain. You need to cut the subdomain from the address, form the name of the base and connect to the desired base.
How can this be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
part_os, 2019-11-02
@part_os

Create your own App\Http\Middleware\Locale::class where you will define the language. And then mark the value in the session and switch the base DB::connection('ru')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question