rhyslees / nova-impersonating-banner
An impersonating banner for Nova 4
Installs: 22 931
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 5
Open Issues: 0
Requires
- php: ^8.2
- laravel/framework: ^10.0|^11.0
- laravel/nova: ^4.0
- livewire/livewire: ^3.0
- rhyslees/nova-about: ^2.0
Requires (Dev)
- laravel/pint: ^1.11
README
- Displays a banner when impersonating
- Allows you to stop impersonating
Prerequisites
Ensure you are using the web
middleware on your routes.
Ensure you have read the Nova Impersonation Docs
Installation
Require this package with composer.
composer require rhyslees/nova-impersonating-banner
php artisan vendor:publish --provider="RhysLees\NovaImpersonatingBanner\NovaImpersonatingBannerServiceProvider"
npm install && npm run build
Displaying the component
Add the following livewire component to your layouts app.blade.php
and guest.blade.php
@livewire('nova-impersonating-banner')
or
<livewire:nova-impersonating-banner />
App Layout app.blade.php
<body class="font-sans antialiased"> <x-jet-banner /> <div class="min-h-screen bg-gray-100"> @livewire('nova-impersonating-banner') @livewire('navigation-menu') ...
Guest Layout guest.blade.php
<body> <div class="font-sans text-gray-900 antialiased"> @livewire('nova-impersonating-banner') {{ $slot }} ...
Customisation
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' => '/', ],