bouncer = $bouncer; } /** * Set the proper Bouncer scope for the incoming request. * * @return mixed */ public function handle(Request $request, Closure $next): Response { $user = $request->user(); $company = $request->header('company'); if (! $company) { $firstCompany = $user->companies()->first(); if (! $firstCompany) { return $next($request); } $company = $firstCompany->id; } $this->bouncer->scope()->to($company); return $next($request); } }