Skip to content

Latest commit

 

History

History
95 lines (69 loc) · 2.24 KB

README.md

File metadata and controls

95 lines (69 loc) · 2.24 KB

Nova Impersonating Banner

  1. Displays a banner when impersonating
  2. Allows you to stop impersonating

image

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' => '/',
],