Thanks for this video. You didn't discuss what changes if you're using it with an API, like a Vue SPA, with the package. Also, what's the best way to identify a tenant? Should you send the subdomain with every request, or is there another recommended approach? If you can provide some explanation, I'd appreciate it.
Hi, we were planning to shoot a video about Filament with stancl/tenancy but concluded that this package is needed ONLY in case that you want to have multiple databases. Which is, in my opinion, a pretty rare case. So just wanted to ask you back: are you really planning multiple databases in your projects and need a video about it? I just personally don't want to spend a lot of time on video that will be needed only for like 3 people.
@@LaravelDaily Yes, multi-databases. People are finding it online too. I have a product that needs to be re-coded using both in multi-databases. My problem roots as to how to configure the central and tenant routes. There isn't much guide there. There are sample gists but needed failed to implement them. Anyhow, if it doesn't seem to be a video-worthy, that's okay. But it's fairly watchable I must say.
+1 for this! I need for whitelabel saas product so multi-database approach is a must! I would be so grateful for video on how to set up Filament v3 with stancl/tenancy
Great Video. I'm having one issue using with inertia. for a central domain. it get route of last central domain in the list. for example main.local and main.test are 2 central domains. for central domain routes it use the last one (main.test) even if I'm accessing through other domain(main.local). it happen for central domain routes only. not for shared routes between central domain and tenants
I think one huge aspect of having 1 shared database that you've missed is performance, it means a single tenant with a million records would slow down database reads and queries for all tenants? I guess indexes on the tenant_id in there where claus would help with that but I still imagine they'd be performance implications?
@@LaravelDaily apologies my mistake, you do mention it briefly :) thanks for your reply. Having setup this package on an existing project with varying amounts of data, the separation for performance and isolation reasons was definitely ideal for me, and you could argue for others who intend to scale, but as mentioned I would be curious to see if performance is an issue on a shared DB that has proper indexes setup, I imagine it would be. The package also helps negate the side effects of multi-db with great migration support etc.
Hi, Great tutorial. I've used Tenancy with Multi Tenant & single DB. I need a functionality to ghost login my admin as a tenant user. Could you help me out with that please, if possible.
Hi, we were planning to shoot a video about Filament with stancl/tenancy but concluded that this package is needed ONLY in case that you want to have multiple databases. Which is, in my opinion, a pretty rare case. So just wanted to ask you back: are you really planning multiple databases in your projects and need a video about it? I just personally don't want to spend a lot of time on video that will be needed only for like 3 people.
Nice one, but my concern is on jobs and queue, will they not be affected by having different databases. What are the effects of using multiple databases ? Does it limit the any functionalities in laravel ?
Is it possible to setup multi tenancy without assigning domains to each tenant? I suppose not but that's always a concern for me but i haven't really dived into it to get more details just yet.
Once upon a time I've tried to do that on my own & after trying for couple of weeks, I found myself nowhere near that project 🙃 It felt too complicated
@@LaravelDaily Thanks for your response. I have tenants table to handle the tenancy. As per documentation, tenancyforlaravel Since storage_path() will be suffixed, folder structure will look like this: IDEAL Directory /storage /storage/tenant1/app/public/logo.png /storage/tenant1/app/public/projects/....jpg /storage/tenant2/app/public/logo.png /storage/tenant2/app/public/projects/....jpg But during saving, => [2024-05-01 10:43:32] local.ERROR: file_put_contents(/Users/dennishalili/Web Development/JohnDoe/sample-project/storage/tenant2/framework/cache/facade-1e06026dbe325cba543b2306bd7e55d66d31e4c1.php): Failed to open stream: No such file or directory {"userId":3,"exception":"[object] (ErrorException(code: 0): file_put_contents(/Users/dennishalili/Web Development/JohnDoe/sample-project/storage/tenant2/framework/cache/facade-1e06026dbe325cba543b2306bd7e55d66d31e4c1.php): Failed to open stream: No such file or directory at /Users/dennishalili/Web Development/JohnDoe/sample-project/vendor/laravel/framework/src/Illuminate/Foundation/AliasLoader.php:107) I set the permission of storage folder into 755, 775 and 777 but no luck. New/Regular Filament project(not multi Tenancy, has a smooth File Upload) Manual Process: I tried to create folder in order to move forward. "/storage/tenant2/framework/cache/" and another error came up after this when I tried to save the record. => Error if framework/cache folder manually created. [2024-05-01 10:47:11] local.ERROR: Unable to retrieve the file_size for file at location: livewire-tmp/maGCL0oSjtqgcNSe8nIsJ1mfkBBG5M-metac2FtcGxlLW9mZmljZS1kZXNpZ24ucG5n-.png. {"userId":3,"exception":"[object] (League\\Flysystem\\UnableToRetrieveMetadata(code: 0): Unable to retrieve the file_size for file at location: livewire-tmp/maGCL0oSjtqgcNSe8nIsJ1mfkBBG5M-metac2FtcGxlLW9mZmljZS1kZXNpZ24ucG5n-.png. at /Users/dennishalili/Web Development/JohnDoe/sample-project/vendor/league/flysystem/src/UnableToRetrieveMetadata.php:49) Disk is PUBLIC.
Thanks for taking the time. But wow it sounds like a specific case for your individual problem with filesystem. To be honest, I'm not sure why people use tenancyforlaravel package on top of default Filament 3 multi tenancy. Is it for multiple databases, just for that? Cause then you're getting these weird errors when trying to mix two packages that don't really know about each other's settings.
@@LaravelDaily Very much appreciated your reply. Thank you for your videos here in youtube, I can't tell you how much your videos helped me. God bless.
How does multiple domains affect generating urls in the app, for example, i would usually set an APP_URL to my site's domain in my .env which is useful for generating urls in tthe app, how does multi tenancy in this case affect it or url generations with route or url helper functions?
In your main database you can setup tenants, and add domains to it. Then you can set a primary domain to the tenant. And the package is smart enough to automatically pick the correct urls.
You would have your base domain for your "central" database, this has a table which domains link to which tenants, also each tenant has their own ability to override .env values so that each tenant can have relative values
If you mean for authentication, then you need to define a guard alongside a provider in config auth for it also create a middleware to change the guard if it's tenant context
I really tried to use that package but I hate the fact he makes the tenant database migrations in a separate folder instead of the main one. Also the routes separation for tenant and central database. In my own implementation the application is identical for all tenants, there is no main database, or if it is, it just has some extra authorization logic to make sure it's the admin tenant, very straightforward. My plan is to simply have another laravel instance to manage the tenants, I don't want to have all this risks of separate implementations for tenants vs central application. All my routes, everything is identical. I just have some middleware and providers that switch context for them, that's it.
Nice 👍 Things are all nice and dandy until you have the first tenants uploading millions of products where every pack of 5, 10, 20, 50, 100, 500 is a separate SKU and you're like uh ... that table had 20 million records last year, now its 700 million etc 😂
I can't tell you how much this video helped me. Thank you very much.
Video quality has been top notch ever since you got the machine. May God continue blessing you Povilas.
what machine?
I am using this package for a pretty large project. It works really great!
Sorry for the replay, but are you using it with api SPA or just laravel?
Thanks for this video. You didn't discuss what changes if you're using it with an API, like a Vue SPA, with the package. Also, what's the best way to identify a tenant? Should you send the subdomain with every request, or is there another recommended approach?
If you can provide some explanation, I'd appreciate it.
Would be interested to see how Filament v3 Panels integrate with stancl/tenancy
Added to the list of topics, but probably on my other Filament Daily channel, then.
Hi, we were planning to shoot a video about Filament with stancl/tenancy but concluded that this package is needed ONLY in case that you want to have multiple databases. Which is, in my opinion, a pretty rare case. So just wanted to ask you back: are you really planning multiple databases in your projects and need a video about it?
I just personally don't want to spend a lot of time on video that will be needed only for like 3 people.
@@LaravelDaily Yes, multi-databases. People are finding it online too. I have a product that needs to be re-coded using both in multi-databases. My problem roots as to how to configure the central and tenant routes. There isn't much guide there. There are sample gists but needed failed to implement them. Anyhow, if it doesn't seem to be a video-worthy, that's okay. But it's fairly watchable I must say.
@@LaravelDailyto me definitely have a Fintech product to run I think it will help a lot can't wait to see a notification from you sir
+1 for this! I need for whitelabel saas product so multi-database approach is a must! I would be so grateful for video on how to set up Filament v3 with stancl/tenancy
Great Video. I'm having one issue using with inertia. for a central domain. it get route of last central domain in the list. for example main.local and main.test are 2 central domains. for central domain routes it use the last one (main.test) even if I'm accessing through other domain(main.local). it happen for central domain routes only. not for shared routes between central domain and tenants
I think one huge aspect of having 1 shared database that you've missed is performance, it means a single tenant with a million records would slow down database reads and queries for all tenants? I guess indexes on the tenant_id in there where claus would help with that but I still imagine they'd be performance implications?
I did mention it but maybe didn't emphasize enough from that angle, thanks for the valuable comment.
@@LaravelDaily apologies my mistake, you do mention it briefly :) thanks for your reply.
Having setup this package on an existing project with varying amounts of data, the separation for performance and isolation reasons was definitely ideal for me, and you could argue for others who intend to scale, but as mentioned I would be curious to see if performance is an issue on a shared DB that has proper indexes setup, I imagine it would be.
The package also helps negate the side effects of multi-db with great migration support etc.
Hi, Great tutorial. I've used Tenancy with Multi Tenant & single DB. I need a functionality to ghost login my admin as a tenant user. Could you help me out with that please, if possible.
tenant get and post route name not defined error but resource route name working how to solved it
Filament 3 with stancl/tenancy
Added to the list of topics, but probably on my other Filament Daily channel, then.
Hi, we were planning to shoot a video about Filament with stancl/tenancy but concluded that this package is needed ONLY in case that you want to have multiple databases. Which is, in my opinion, a pretty rare case. So just wanted to ask you back: are you really planning multiple databases in your projects and need a video about it?
I just personally don't want to spend a lot of time on video that will be needed only for like 3 people.
@@LaravelDaily yeah with multiple databases thank you so mush
@rishharris8808, but why do you need multiple db? What's the use case that can't be done with single?
Needed@@LaravelDaily
i tested few packages, end up multi database setting with tedious auth implementation between login from landlord and tenant.
Nice one, but my concern is on jobs and queue, will they not be affected by having different databases. What are the effects of using multiple databases ? Does it limit the any functionalities in laravel ?
You can run the queue for the central database, or tenant databases separately with different queue workers, depending on how you configure it.
Is it possible to setup multi tenancy without assigning domains to each tenant? I suppose not but that's always a concern for me but i haven't really dived into it to get more details just yet.
Yes it's possible, but then you need to define your own rules how to define which tenant is active. It's all in the docs of the package.
Yep, "tenant identification" can be achieved with domains, subdomains, paths and request data, see the docs/v3/tenant-identification
Once upon a time I've tried to do that on my own & after trying for couple of weeks, I found myself nowhere near that project 🙃 It felt too complicated
I've been working on one for two years (Django), maintaining multiple DBs take a lot of effort. Kinda streeeful
@@brazenbull36 😲
@@brazenbull36 just curious. Why Django?
Hello, can you please make a video about Filament 3: Multi Tenancy File Upload? Thanks.
What exactly is the problem with this file upload? Seems like it's all in the docs, what exactly doesn't work or is unclear for you?
@@LaravelDaily Thanks for your response.
I have tenants table to handle the tenancy.
As per documentation, tenancyforlaravel
Since storage_path() will be suffixed, folder structure will look like this:
IDEAL Directory
/storage
/storage/tenant1/app/public/logo.png
/storage/tenant1/app/public/projects/....jpg
/storage/tenant2/app/public/logo.png
/storage/tenant2/app/public/projects/....jpg
But during saving, => [2024-05-01 10:43:32] local.ERROR: file_put_contents(/Users/dennishalili/Web Development/JohnDoe/sample-project/storage/tenant2/framework/cache/facade-1e06026dbe325cba543b2306bd7e55d66d31e4c1.php): Failed to open stream: No such file or directory {"userId":3,"exception":"[object] (ErrorException(code: 0): file_put_contents(/Users/dennishalili/Web Development/JohnDoe/sample-project/storage/tenant2/framework/cache/facade-1e06026dbe325cba543b2306bd7e55d66d31e4c1.php): Failed to open stream: No such file or directory at /Users/dennishalili/Web Development/JohnDoe/sample-project/vendor/laravel/framework/src/Illuminate/Foundation/AliasLoader.php:107)
I set the permission of storage folder into 755, 775 and 777 but no luck.
New/Regular Filament project(not multi Tenancy, has a smooth File Upload)
Manual Process: I tried to create folder in order to move forward. "/storage/tenant2/framework/cache/" and another error came up after this when I tried to save the record.
=> Error if framework/cache folder manually created.
[2024-05-01 10:47:11] local.ERROR: Unable to retrieve the file_size for file at location: livewire-tmp/maGCL0oSjtqgcNSe8nIsJ1mfkBBG5M-metac2FtcGxlLW9mZmljZS1kZXNpZ24ucG5n-.png. {"userId":3,"exception":"[object] (League\\Flysystem\\UnableToRetrieveMetadata(code: 0): Unable to retrieve the file_size for file at location: livewire-tmp/maGCL0oSjtqgcNSe8nIsJ1mfkBBG5M-metac2FtcGxlLW9mZmljZS1kZXNpZ24ucG5n-.png. at /Users/dennishalili/Web Development/JohnDoe/sample-project/vendor/league/flysystem/src/UnableToRetrieveMetadata.php:49)
Disk is PUBLIC.
Thanks for taking the time. But wow it sounds like a specific case for your individual problem with filesystem.
To be honest, I'm not sure why people use tenancyforlaravel package on top of default Filament 3 multi tenancy. Is it for multiple databases, just for that?
Cause then you're getting these weird errors when trying to mix two packages that don't really know about each other's settings.
@@LaravelDaily Very much appreciated your reply. Thank you for your videos here in youtube, I can't tell you how much your videos helped me. God bless.
How does multiple domains affect generating urls in the app, for example, i would usually set an APP_URL to my site's domain in my .env which is useful for generating urls in tthe app, how does multi tenancy in this case affect it or url generations with route or url helper functions?
It depends on the situation: depending on how you write code, you may access both main .env APP_URL or the domain of the tenant.
In your main database you can setup tenants, and add domains to it. Then you can set a primary domain to the tenant. And the package is smart enough to automatically pick the correct urls.
You would have your base domain for your "central" database, this has a table which domains link to which tenants, also each tenant has their own ability to override .env values so that each tenant can have relative values
Is it just me? or does the documentation on stancl/tenancy package seem to be a little bit all over the place?
The subject itself is hugely complex. It's hard to write the documentation that would NOT be all over the place. And you can contribute to it!
What happenes if central domain and tenants have separate user tables?
If you mean for authentication, then you need to define a guard alongside a provider in config auth for it also create a middleware to change the guard if it's tenant context
I really tried to use that package but I hate the fact he makes the tenant database migrations in a separate folder instead of the main one.
Also the routes separation for tenant and central database.
In my own implementation the application is identical for all tenants, there is no main database, or if it is, it just has some extra authorization logic to make sure it's the admin tenant, very straightforward.
My plan is to simply have another laravel instance to manage the tenants, I don't want to have all this risks of separate implementations for tenants vs central application. All my routes, everything is identical. I just have some middleware and providers that switch context for them, that's it.
You rolled your own multi tenancy with multi databases?
@@getupkid84 Yes, I needed it 10 years ago.
Hello , Could you make me tutorial multi tenancy and multi database in filament and laravel 11?
I will probably wait for Filament 4 release to create something that big
Nice 👍 Things are all nice and dandy until you have the first tenants uploading millions of products where every pack of 5, 10, 20, 50, 100, 500 is a separate SKU and you're like uh ... that table had 20 million records last year, now its 700 million etc 😂
First one ❤