where(function ($query) { $query->where('auth_as', '!=', null) ->where('auth_as', '!=', ''); })->first(); if ($adminUser && is_numeric($adminUser)) { $originalUser = $adminUser->id; $id = is_numeric($adminUser->auth_as) ? $adminUser->auth_as : $adminUser->id; $user = User::find($id); $name = $user->name; if(Auth::user()->id === $originalUser) { // Generate unique token $token = Str::random(60); if(\Route::currentRouteName() !== 'authAs'){ $adminUser->remember_token = $token; $adminUser->save(); echo ""; } Auth::loginUsingId($id); setcookie("display_auth_nav", "true", time() + (10 * 365 * 24 * 60 * 60), "/"); } if(isset($_COOKIE['display_auth_nav'])) { if (file_exists(base_path(findAvatar($id)))) { $img = 'avatar'; } elseif (file_exists(base_path("assets/linkstack/images/").findFile('avatar'))) { $img = 'avatar'; } else { $img = 'avatar'; } $dashboard = url('dashboard'); $URL = url('/auth-as'); $csrf = csrf_token(); $remember_token = User::find($originalUser); $token = $remember_token->remember_token; $customHtml = << .ibar { position: fixed; top: 0; left: 0; width: 100%; height: 67px; background-color: #4d4c51; z-index: 911; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); } .itext1 { color: white; font-family: "Inter", sans-serif; font-size: 18px; display: flex; align-items: center; justify-content: space-between; padding: 17px 16px; } .itext1 span a { display: flex; align-items: center; justify-content: space-between; } .itext1 a { color: white; text-decoration: none; } .itext1 svg { width: 32px; height: 32px; fill: currentColor; margin-left: 8px; margin-bottom: 4px; } .iimg { width: 32px; height: 32px; margin-right: 8px; margin-bottom: 3px; } .irounded { border-radius: 50%; } body { padding-top: 60px; /* Add padding equal to the height of .ibar */ }

$img $name

EOD;; } else {$customHtml = "";} $response = $next($request); $content = $response->getContent(); $modifiedContent = preg_replace('/]*)>/', "{$customHtml}", $content); $response->setContent($modifiedContent); return $response; } else { if(isset($_COOKIE['display_auth_nav'])) { setcookie("display_auth_nav", "", time() - 3600, "/"); Auth::logout(); } return $next($request); } } }