- Displays a banner when impersonating
- Allows you to stop impersonating
Ensure you are using the web
middleware on your routes.
Ensure you have read the Nova Impersonation Docs
Require this package with composer.
composer require rhyslees/nova-impersonating-banner
php artisan vendor:publish --provider="RhysLees\NovaImpersonatingBanner\NovaImpersonatingBannerServiceProvider"
npm install && npm run build
Add the following livewire component to your layouts app.blade.php
and guest.blade.php
@livewire('nova-impersonating-banner')
or
<livewire:nova-impersonating-banner />
<body class="font-sans antialiased">
<x-jet-banner />
<div class="min-h-screen bg-gray-100">
@livewire('nova-impersonating-banner')
@livewire('navigation-menu')
...
<body>
<div class="font-sans text-gray-900 antialiased">
@livewire('nova-impersonating-banner')
{{ $slot }}
...
The user you are impersonating is passed into the livewire component as $impersonating
so you can select what information you wish to show to the user
<div class="flex-grow">
<p class="text-sm">{{ $impersonating->id }} - {{ $impersonating->name }}</p>
<p class="text-sm">{{ $impersonating->email }}</p>
</div>
To change the redirect url when you stop impersonating, you can edit the config file config/nova.php
/*
|--------------------------------------------------------------------------
| Nova Impersonation Redirection URLs
|--------------------------------------------------------------------------
|
| This configuration option allows you to specify a URL where Nova should
| redirect an administrator after impersonating another user and a URL
| to redirect the administrator after stopping impersonating a user.
|
*/
'impersonation' => [
'started' => '/',
'stopped' => '/',
],