hipsterjazzbo / Landlord

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

Is it possible to throw ModelNotFoundForTenantException with firstOrFail #54

Closed illmatic closed 7 years ago

illmatic commented 7 years ago

I ran into a route model binding issue with my Tenant Middleware so I decided to forego that. I'm also using a Sluggable package and don't want my URLs to show the index value. I tried firstOrFail with a slug condition but it simply returned a ModelNotFoundException.

Is there any way to make this work beyond doing an extra query to look up the ID based on slug?

inctor commented 7 years ago

You could either do an "allTenants()" or overwrite the built in "firstOrFail", just as this package overwrites "findOrFail". If it's for getting the row, i'd suggest using the built in "findOrFail" that this package overwrites.

Otherwise, it may be easier to just make a separate query to look it up, if you don't want to make a pull-request or fork it yourself :)