Coder Social home page Coder Social logo

multitenancy's People

Contributors

bradenkeith avatar consoletvs avatar dependabot[bot] avatar joriskuijpers avatar kylebarney avatar madurapa avatar naoray avatar tomhatzer avatar wojciechgabrys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

multitenancy's Issues

Custom UnauthorizedException Messages

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.

Event on Tenant Match

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 👍

Problem bigincrements

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)

Migration rollback fails

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.

have simple question

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

Cannot scoping based on tenants

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

Accessing the current tenant?

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();

Relation

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?

Password resets...

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?

Making routes bypass the tenant middleware

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 scope user by tenant

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.

Tenant Route Model binding not working?

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;

  • Register RomegaDigital\Multitenancy\MultitenancyServiceProvider::class in config/app.php
  • Run php artisan multitenancy:install
  • Add HasTenants, HasRoles to User model
  • Add BelongsToTenant to Product model
  • Add 'tenant.auth' => \RomegaDigital\Multitenancy\Middleware\TenantMiddleware::class to routeMiddleware in app/Http/Kernel.php
  • I have then wrapped by routes in the route group as below
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.

Class RomegaDigital\Multitenancy\Middleware\GuestTenantMiddleware does not exist

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

Question about this package

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

Domains

Thank you for this gorgeous package.
How can we add different domains instead of subdomains?

Thank you

must be an instance of App\User, instance of App\Domain\User given

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 !

Middleware hits database everytime?

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.

Question about routes

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!

Column 'tenant_id' is ambiguous when using Joins

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?

Tenant::createMany not found, can't get it to work

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'
            ]
        ]);
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.