Closed renanwilliam closed 6 years ago
Any chance we can get this merged or reviewed?
I was actually hoping this solved the issue where applying the tenant scope in a group middleware doesn't work, but that isn't the case with this PR
Nevermind on my last comment. I missed the part where I need to run Landlord::applyTenantScopesToDeferredModels();
after the Landlord::addTenant()
call. Works for me! Thanks @renanwilliam and @pimski
@renanwilliam would you mind explaining what the 2nd and 3rd commits fix? I have two tenant scopes and the first() logic is incorrectly choosing which tenant scope to apply
@ryross it's for the cases when I change the tenant before a scope is applied.
@renanwilliam You might want to find a different way to do that. Your logic breaks the code for folks who have two tenants. It resets the ID. @HipsterJazzbo Did you test this?
Hi @ryross , I have executed all previous test cases and the new test case write for the change and it not happens, no problems for me (we are also using it in a production project with 5 tenants and everything looks fine). Do you have a test case or instructions do check this error?
Solution provided by pimski for deferred scope apply to models booted before Tenants setup.