Category : multi-tenant

I’m using tenancy on Laravel v8 with Passport and PostgreSQL using the Multi-Schema model. On my old server and with MySQL everything was fine, but after moving to the new setup, I’m facing an error on tenant creation: PDOException: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oauth_clients" does not exist and this happens after running $clientRepository->createPersonalAccessClient(…) ..

Read more

I’m using this package[https://tenancyforlaravel.com/] to make multi tenancy possible, each time i create new tenant i got new database, working great locally But when i moved to live server/cpanel i get SQLSTATE[42000]: Syntax error or access violation: 1044 Access denied for user ‘test’@’localhost’ to database ‘tenantnew’ (SQL: CREATE DATABASE `tenantnew` CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci`) ..

Read more

Im trying to test the Tenancy functionality via PHP Unit test but there are errors coming out. Fatal error: Cannot declare class CreateUsersTable, because the name is already in use in /var/www/database/migrations/tenant/2014_10_12_000000_create_users_table.php on line 54 I already test the migration but there is a different when running on unit test. This error only appear when ..

Read more

I am building SaaS Application using stancl/tenancy package, and I am using sub-domains to detect the current tenant used. My problem is "Shared Session Between Tenants" so I want to prevent that, and as mentioned in https://tenancyforlaravel.com/docs/v3/session-scoping/#storing-sessions-in-the-database I should be able to store sessions in tenants databases so it will be private for that tenant, ..

Read more

I need to pass/set custom header from Nginx block to server (not response header) to detect the tenant. I have tried with Nginx proxy but failed: Here is my code: server { server_name app.another.com www.app.another.com; location / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header tenant-id 1001; proxy_pass …domain.com ; proxy_redirect …domain.com ….app.another.com; } } ..

Read more

I’m making a multitenancy system and I’m facing problem when trying to handle the NoCurrentTenant Exception.. I’m using spatie multitenancy I’m expecting that when there is NoCurrentTenant exception is thrown , it should redirect to login route. But that is not happening. Below is my Exception Hander register method. public function register() { $this->reportable(function (NoCurrentTenant ..

Read more

I want to convert my existing app to multi-tenant and don’t want to use multiple databases. just read that the given package is allowing that. https://github.com/spatie/laravel-multitenancy I have read the single database documentation here: https://spatie.be/docs/laravel-multitenancy/v2/installation/using-a-single-database But what’s next ?? Let’s say right now users are storing into users’ tables, and by using this package I ..

Read more

I want to make multitenant solution with multiple databases (one DB per tenant). Central domain for instance example.com has things like registration form and login form e.g example.com/sign-in Each customer is a new tenant identified by sub domain e.g foo.example.com Sign in process (happy scenario) User see view called e.g sign-in on central domain User ..

Read more

I am trying to connect to tenant connection. when I execute ( new Tenant())->configure()->use(); Abd check in logs Log::info(DB::connection()->getDatabaseName()); it is still pointing to main connection and database Log::info(DB::connection(‘tenant’)->getDatabaseName()); If try the above it shows connect to right database; How to reset db connection namespace AppModels; use IlluminateDatabaseEloquentFactoriesHasFactory; use JenssegersMongodbEloquentModel; use IlluminateSupportFacadesDB; use IlluminateSupportFacadesSchema; class ..

Read more

When I try to do this php artisan migrate –path=database/migrations/landlord –database=landlord I get the following error: PS C:laragonwwwcommerce> php artisan migrate –path=database/migrations/landlord –database=landlord ************************************** * Application In Production! * ************************************** Do you really wish to run this command? (yes/no) [no]: > y Dropped all tables successfully. IlluminateDatabaseQueryException SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect ..

Read more

I was using image/intervention package to upload files and store. and for this package I store files lik $img = Image::make($imageFile); $img->save($full_path.$filename); But now, using tenancy, the files are stored and can be access globally, I want to store files tenant specific. How to do it? As per the Stancl/tenancy doc. Storage::disk(‘public’)->put($filename, $data); can help. ..

Read more