romegasoftware / multitenancy Goto Github PK
View Code? Open in Web Editor NEWA simple and opinionated package for providing subdomain based multi-tenancy to Laravel
License: MIT License
A simple and opinionated package for providing subdomain based multi-tenancy to Laravel
License: MIT License
Thank you for this gergous package.
I think it would be nice to be able to customize UnauthorizedException messages. If you want I can send a PR.
Thank you for the package!
I'm currently using this package in conjunction with Nova and the Nova Multitenancy package that youve created.
Currently, I dont see that there's any way to handle tasks when a tenant is established within the app (e.g. changing configs based on current tenant).
Maybe an event thats fired when the tenant is saved within the ioc container?
Maybe I'm overlooking it?
If not, before I implement my own system for it, is there any plan to add this for the package? If so, anytime soon?
I'd prefer to utilize the package logic where possible.
Thanks again for these packages, really helping so far 👍
Hi! Congrats for this awsome package.
Well, I dont know if this is really and issue or only something weird happening inside my computer, but I was getting the following error:
"SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table tenant_user
add constraint tenant_user_user_id_foreign
foreign key (user_id
) references users
(id
) on delete cascade)"
So I changed inside the users migration from "$table->bigIncrements('id');" to "$table->increments('id');" and it fixed the problem.
My MySql version: 5.7
Windows (Laragon)
Hi I have a brand new installation of a NOVA application, I followed the steps installing this package. In the step when I want to assign my user as admin I see this error:
User model \App\User can not be found!
Maybe is just something simple, hope you guys can give me some insight.
Thanks in advance.
The php artisan migrate:rollback
command fails because the foreign key constraint is not removed in the down
method of the create_tenants_table.php.stub
file prior to attempting to drop the tenant_user
table. PR on the way.
hi .
do this package support a user with multi tenancy ?
1- user register and login the profile are the create multi tenant with multi subdomain .
2- click to each subdomain then open it without login because subdomain itself???
please help me
php artisan multitenancy:migration time_cards
Needs to create migration class of AddTenantIdColumnToTimeCardsTable
Actually creates AddTenantIDColumnToTime_cardsTable
I cannot scoping category by tenant with param injection, code like this
routes/web.php
Route::group(['middleware' => ['tenant.guest']], function () {
Route::get('/show/{category}', 'CategoryController@show');
});
and on App/Controller/CategoryController.php
public function show(Category $category)
{
return $category;
}
on model App/Models/Category.php
class Category extends Model
{
use BelongsToTenant;
}
Is there an error in my code? Or there is an idea for this
Hey,
What's the best way to go about accessing the current tenant?
Thanks
Edit:
Not sure why I didn't try this first, but you can call
MultitenancyFacade::receiveTenantFromRequest();
Hi,
I know that I can use the console command to add a new related belongs to model
use Illuminate\Database\Eloquent\Model;
use RomegaDigital\Multitenancy\Traits\BelongsToTenant;
class Product extends Model
{
use BelongsToTenant;
// ...
}
But what about the other way around?
I think there is a possible session data leakage as session storage is not separated by tenants
See https://www.youtube.com/watch?v=cjWEZ5SKvIY
Howdy,
Thanks so much for making this package, it has helped me out tremendously. I just ran into an issue that I'm not sure how to handle. If a user resets their password from a subdomain, the link they get in their email has the subdomain removed. So when they change their password they get sent to the main domain, which doesn't work for them.
How can I get around that?
Hi,
What is the best approach to bypass the tenant middlewares?
Available for tenants (backoffice) ==> tenant.auth
tenant.domain.com/
tenant.domain.com/dashboard
tenant.domain.com/products/add
Available for customers of tenants ==> tenant.guest
tenant.domain.com/form-to-some-guest-logic
Available for everyone without a scope/tenant middleware
domain.com/
domain.com/register (logic to let visitors create themself as tenant)
==> This doesn't workt at this moment. As soon as I define a Route::get('/', ...)
all visitors, subdomain or not will return to the domain.com/ endpoint. And it should deffer based on when there is an tenant-subdomain or not.
How to sending reset password link specific subdomain?
Hi,
I really like your package! How can I scope the user by its tenant?
For Example: A tenant (name und domain: company1) has five user. Each user should only the the users of its associated company1.
So \App\User::get();
Should only return the five users for company1.
Not sure if I'm missing something but when trying to create tenant's and users using model factories, it doesn't seem to be working.
Kind Regards
Hey All,
I'm trying to dig into this but running into a few issues. I might be missing something as this seems like something that would work out of the box based on the documentation.
Currently, I have a product owned by Tenant 1
http://tenant1.exampledomain.test/products/2
If I then log in as Tenant 2 and navigate to this URL
http://tenant2.exampledomain.test/products/2
Then I can see the contents of that product, although I assume I shouldn't?
Quick run down as per the docs;
Route::group(['middleware' => ['tenant.auth']], function () {
Route::resource('/products', 'ProductController');
});
Am I missing something, or does tenant route model binding not work out of the box? My expectation here would be a 403 response to the user.
Thanks for any feedback, and let me know if I can provide more helpful info to debug.
after im following your instruction and i will show product related with tenant. Show error : Class RomegaDigital\Multitenancy\Middleware\GuestTenantMiddleware does not exist,
I have included the middleware route group on Kernel.php
I see in romegadigital folder on vendors, just looking at the TenantMiddleware.php middleware, I did not find GuestTenantMiddleware.php
Maybe you haven't updated your latest package version on composer
What happen? can you help me
Hey there!
Thanks for creating this package and providing it as open source.
I've just got a small question about it: Is this package basically only for logged in/authorized users?
I'd love to use this to provide multitenancy for non-authorized users, basically a system where there are multiple websites running on different domains or subdomains and non-authorized users can visit those domains and browse through the contents of the corresponding tenant.
There's currently one part of code that's denying this:
https://github.com/romegadigital/Multitenancy/blob/98796699b2f4766510d00c63d614fc8b1ee622e3/src/Middleware/TenantMiddleware.php#L40-L42
This snippet is triggered every single time as my users are not logged in (just regular website visitors). Would it be possible to make this optional (through a variable in the config or .env file maybe?). I could also provide a PR for this if you want.
Thank you very much!
Best wishes
Tom
Thank you for this gorgeous package.
How can we add different domains instead of subdomains?
Thank you
Argument 1 passed to RomegaDigital\MultitenancyNovaTool\Policies\RolePolicy::before()
must be an instance of App\User, instance of App\Domain\User given,
called in /var/www/vhosts/xx/yy/vendor/laravel/framework/src/Illuminate/Auth/Access/Gate.php on line 683
(View: /var/www/vhosts/xx/yy/resources/views/vendor/nova/layout.blade.php)
config allows setting config('multitenancy.user_model')
but then forces App\User !
Hi, I realized that middleware queries database each time for a route. Instead of that can we like put the tenant info in session or something like that? Please suggest me its pros and cons.
Hey,
I've only just started playing around with this package, so the answer might be obvious if I spent some more time.
I've modified the login the controller so that it directs the user to their subdomain (assuming they only have one tenancy).
How does routing work with this? E.g. if I called route('dashboard')
for example, will that include their subdomain?
Sorry if the answer is obvious or I haven't spent enough time with it.
Thanks!
Hi there,
Firstly thank you for your work on this project, it's made what I plan to do so much easier.
However, I'm having issues using this package when using join statements between two models that inherit scoping of the current tenant.
I believe this is due to the where clause that looks for the tenant_id
being ambiguous since both models have the tenant_id
in them and a specific tenant_id
is not specified i.e.table_name.tenant_id
.
Would you consider this an issue? or do you have any recommendations for resolving this?
After doing everything right according to the readme, I get the following error:
Call to undefined method RomegaDigital\Multitenancy\Models\Tenant::createMany()
When attempting:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use RomegaDigital\Multitenancy\Models\Tenant;
class TestController extends Controller
{
public function __invoke()
{
Tenant::createMany([
[
'name' => 'An Identifying Name',
'domain' => 'tenant1'
],
[
'name' => 'A Second Customer',
'domain' => 'tenant2'
]
]);
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.