PHP Rebuild
CI / ci (push) Canceled after 0s

Initial PHP rebuild of the app
This commit is contained in:
Stefan Lazic committed 2026-09-05 08:21:33 +01:00
1 parent 8a2b211069
commit 2ef3654841
690 files changed
+33944 -12046

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
<?php
namespace App\Http\Middleware;
use App\Models\Business;
use App\Models\BusinessDomain;
use App\Services\Tenant\TenantContext;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
class ResolveTenant
{
public function handle(Request $request, Closure $next): Response
{
$hostname = strtolower(rtrim($request->getHost(), '.'));
try {
$business = BusinessDomain::query()
->where('hostname', $hostname)
->where('isActive', true)
->with('business')
->first()?->business;
if (! $business && app()->environment('local')) {
$slug = config('app.default_business_slug');
$business = $slug
? Business::query()->where('slug', $slug)->first()
: null;
}
} catch (Throwable) {
// The install page and framework smoke tests must remain
// reachable before the tenant schema has been created.
$business = null;
}
if ($business) {
app(TenantContext::class)->set($business);
}
return $next($request);
}
}