tenancy / multi-tenant

Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously github.com/hyn/multi-tenant
https://tenancy.dev
MIT License
2.56k stars 394 forks source link

Environment Class is stuck on Tenant #982

Closed publicdesigners closed 3 years ago

publicdesigners commented 3 years ago

Hi All,

Firstly what a great package really enjoyed working with it. I have seemed to have broken my app by forcing the app to use the tenant connection:

https://tenancy.dev/docs/hyn/5.6/identification https://tenancy.dev/docs/hyn/5.6/connections

I would like to get the app back to how it was on the default install i.e. using the system connection then switch automatically to the tenants. I know the app has now bound the environment class to the Laravel container "tenant" how would i go about switching it back to "system"?

I know i will have to call a boot function in the AppServiceProvider.php but from the documentation i can't figure out the code to switch it to system?

Thanks

ogunsakin01 commented 3 years ago

Hi, I think you should remove the force identification and allow auto identification in your config/tenancy.php. Also separate your tenant and system models into different folders and make use of UsesSystemConnection or UsesTenantConnection traits on your system or tenant models accordingly.

publicdesigners commented 3 years ago

Hi, Thanks for the reply. This is the issue i have removed the force identification and the auto identification is set to true. But the app still uses tenant instead of system?

ogunsakin01 commented 3 years ago

When you say uses tenant, do you mean the routes or database connection or both? If you were previously forcing the tenant connection in you AppServiceProvider, you will need to run cache:clear and config:cache command afterwards.

publicdesigners commented 3 years ago

Yes cleared app caches multiple times including browser, just found something out! The app works normally in chrome, firefox but its only safari that i'm getting this issue!!!! Launched the app to a live environment and that works in all browsers too.

I expect it might be session or an issue with safari caching localhost (swapping browser for now) but thanks for you input and help OgunsakinDamilola

ogunsakin01 commented 3 years ago

Oh,great. I am glad it's all good now.