hipsterjazzbo / Landlord

A simple, single database multi-tenancy solution for Laravel 5.2+
MIT License
614 stars 138 forks source link

Implicit Model Biding with LandLord #62

Closed bissolli closed 7 years ago

bissolli commented 7 years ago

Hey guys!

I started using implicit model binding and LandLord isn't working anymore! I think it is happening because when the model binding do their job I didn't set LandLord tenant yet! Somebody know any trick to do that?

There is how my code works now:

lasseeee commented 7 years ago

Does the scope apply to no models at all, or just not the User (or whatever models extends Authenticatable)?

patroniton commented 7 years ago

IIRC you need to put the middleware that handles the tenants in the global middleware array in App\Http\Kernel.php (not the routemiddleware array). That way it's handled before any implicit route binding.

hipsterjazzbo commented 7 years ago

Yeah, this is by far the most common type of issue for this package, but the answer is: make sure you're adding tenants before you need them :)

renanwilliam commented 7 years ago

@HipsterJazzbo Considering that I can't add tenant before the auth (single domain application), how can do it?