Sep 9, 2018 · 1 min read
$tenant = Tenant::whereSlug($subdomain)->first() ?: abort(404);can be changed to:
$tenant = Tenant::whereSlug($subdomain)->firstOrFail();Same effect.
Also, the use of whereSlug is a magic function, making it x3 times slower (check some benchmarks) than native function call. So let’s address this by using the following:
$tenant = Tenant::where('slug', $subdomain)->firstOrFail();