Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIth multiple tenants Landlord uses first tenant id for the other tenant scopes #82

Open
rikvdlooi opened this issue Oct 17, 2017 · 3 comments

Comments

@rikvdlooi
Copy link
Contributor

When you scope on multiple tenants Landlord, landlord will use the id of the first tenant on all other tenants.

How to reproduce (some 'pseudo' code):

Model with two different tenants

class MyModel extends Model {
    use BelongsToTenants;

    public $tenantColumns = ['tenant_a_id', 'tenant_b_id'];
}

Add Tenants

Landlord::AddTenant('tenant_a_id', 1);
Landlord::AddTenant('tenant_b_id', 2);

Get results

MyModel::all();

If you use barryvdh/laravel-debugbar you can see that the query will be like this:

select * from my_model where tenant_a_id = 1 and tenant_b_id = 1;

The $id for Tenant A is also used for the scope of Tenant B.

@aluferraz
Copy link

I think this is the same case as #85

@rikvdlooi
Copy link
Contributor Author

Yes @aluferraz. It looks like it is the same issue. At least (almost) the same solution.

@aluferraz
Copy link

@hipsterjazzbo any thoughts on this ? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants