In multi level tenancy am using laravel middleware to change the database connection in laravel. but stuck in the queue, is there any option to pass the database string to queue of laravel.
Related
I am learning astrojs and want to build sample project connectingn to laravel session auth using breeze + api. How can we establish and maintain a session between laravel and astrojs SSR?
We are working on project where multiple databases are connected. We have created connections i.e. dbconnection1 and api. We are facing problem in connecting sanctum auth to different connection i.e. api after upgrading Laravel to 9.
Earlier it was working perfectly, after upgrading Laravel version, we could not connect to different connection.
We have mentioned connection in respective Modal i.e. protected $connection = 'api';.
But still sanctum is not connecting to correct database. Currently we have extended PersonalAccessToken Model as per sanctum documentation and added protected $connection = 'api'; line there.
But we would like to know if there is any better option for this? As We don't think just to mention connection we should extend PersonalAccessToken Model.
You are correct, since PersonalAccessToken extends Model, which by default uses the default connection, you need to specify different connection like other models.
Otherwise you can set 'api' as the default connection
I'm building an app where each subdomain has its own database.
For example:
"example1.app.dev" uses "example1_dbo" database
"example2.app.dev" uses "example2_dbo" database
Each subdomain has its own users, meaning that for example:
user_ex1 can only login on example1.app.dev because he is set in example1_dbo
user_ex2 can only login on example2.app.dev because he is set in example2_dbo
How do I achieve this with Laravel Auth?
Basicaly I have set subdomain routing:
Route::domain('{account}.myapp.dev')->group(function () {})
And i have set up database connections in config/database.php and env file.
I have used this concept on Eloquent models with Model->setConnection($account)
But this method is exhausting while app is growing...
I'm looking for Middleware solution where i can change default DB connection for request globally and for Auth as well while i was not able to get authentication to work.
Have you tried this package:
https://github.com/stancl/tenancy
It provide that out of the box.
hope it is helpful.
I use Laravel Framwork for all my php projects, and I am wondering if Laravel 5* store user critical information in session or cookies. I mean in server side or client side.
im building an application with laravel 4.2
Id like to know how laravel remove sessions records on DB after Auth::logout() call...
Its still there in my table.. with an empty payload but still there
thanks for reply