Backpack and Multi tenancy #733
Replies: 6 comments 8 replies
-
This. Is. AWESOME! Thanks a lot for sharing your findings about this @exorgroup ! I'm am 100% this will help someone someday. I do the same - when I do something that's out-of-the-ordinary I document it. For myself and possibly others. I've taken the liberty of editing your post slightly, added Moved to "Show and tell" since I think it's more appropriate there. Thanks again for sharing this! |
Beta Was this translation helpful? Give feedback.
-
Hi, Over the past few days, I've been working on implementing multi-tenancy in my Backpack application, which involves using multiple databases and identifying tenants based on either subdomains or paths. When working with a fresh Laravel application, I followed the tenancy documentation, and everything worked smoothly with Breeze. I was able to successfully log in/register for both central and tenant databases and retrieve the correct user information. However, I've encountered some challenges when trying to integrate Backpack into the setup. I suspect that I might not have a clear understanding of how to use middlewares and routes correctly, as I'm facing various issues. For instance, attempting to log in as a tenant with a central user, or trying to access any CRUD route, results in a "419 PAGE EXPIRED" error. I would greatly appreciate it if anyone could provide a concise guide on how to effectively use these two excellent packages together. Specifically, I would like to know which route file should utilize the tenant middleware and which should use the central middleware. Thank you in advance for your assistance! |
Beta Was this translation helpful? Give feedback.
-
Hi @exorgroup Thank you so much for this. I am looking to do the exact same. I have Tenancy For Laravel and was trying to use Nova with very little success when trying to create a form builder. Coming across Backpack seems to be the best option! I would love to hear how you have got on with your development. Anything I should watch out for, any tips and tricks. I would really appreciate any advice that you can share. Many thanks Jack |
Beta Was this translation helpful? Give feedback.
-
@tabacitu I used to build SaaS applciations with backpack but there were some issues that needs to be adjusted by backpack himself, especially for the BL when we reach out the model instances. |
Beta Was this translation helpful? Give feedback.
-
used backpack for admin panel and I was able to pass tenant related data in it, but its not so stable as expected. especially when updating creating data the redirects are giving pain in the a$$ :) |
Beta Was this translation helpful? Give feedback.
-
@exorgroup since Laravel 11 doesn't have |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am implementing backpack in a multi tenancy application specifically using https://tenancyforlaravel.com/. I know this is uncharted territory for me and may be for many but would like to share my experience here and may be receive some feedback to improve it
So here is my two cents to this:
Step 1:
To install make sure you have a users table in the main database where the domains and tenants tables are - it is required for initial intall.
Step 2:
Once it installs it will log against the main table - change file
config\backpack\base.php
by'web_middleware' => 'web'
Step 3:
Change file
app\Http\Kernel.php
by adding the following references tomiddlewareGroups
:This allows you to log in against each tenant database and not the main database.
Devtools
I have started to use this and have no issues in generating most of the steps. The only step that needs to be altered is the migration stage. Do not migrate with devtools as it will migrate to the main database. This I step in manually shifting the migrations to the tenancy folder as described in the Stancl Tenancy documentation and perform a
tenancy migrate
instead orartisan migrate
. The rest is per devtools documentation and works fine. I suppose that the migrate can be sorted as well by adjusting the code somewhere but did not look into that.So far it works and have everything being generated in a multi tenant environment - if I broke something with these actions please let me know and potentially how it can be fixed but so far it seems to work good.
C Ya and regards to all
Beta Was this translation helpful? Give feedback.
All reactions