spatie / laravel-multitenancy

Make your Laravel app usable by multiple tenants
https://spatie.be/docs/laravel-multitenancy
MIT License
1.11k stars 153 forks source link

Update Landlord.php #464

Closed 1cbyc closed 1 year ago

1cbyc commented 1 year ago

You should sometimes try something new with your code, you know. I tried wrapping the callable inside a try-finally block, so that the original tenant is always restored, even if an exception is thrown. You see that 'makeCurrent()' method, I made sure it calls on the original tenant ONLY if it exists, using the null coalescing operator ($originalCurrentTenant?->makeCurrent()). This will prevent an error in case the '$originalCurrentTenant' variable is null.

masterix21 commented 1 year ago

Hi @1cbyc, there is no reason to prefer a try/catch here. Thanks for your time on it, anyway.