PHP code example of genealabs / laravel-impersonator

1. Go to this page and download the library: Download genealabs/laravel-impersonator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

genealabs / laravel-impersonator example snippets


  @if ((auth()->user()->canImpersonate ?? false) && ! session('impersonator'))
      <a class="dropdown-item" href="{{ route('impersonatees.index') }}">Impersonator</a>
  @endif
  

  @if (session('impersonator'))
      <a href="{{ url('/logout') }}"
          class="dropdown-item"
          onclick="event.preventDefault(); document.getElementById('end-personation-session-form').submit();"
      >
          End Impersonation Session
      </a>
      <form action="{{ route('impersonatees.destroy', auth()->user()) }}"
          method="POST"
          style="display: none;"
          id="end-personation-session-form"
      >
          {{ csrf_field () }}
          {{ method_field ('DELETE') }}
      </form>
  @else
      <a href="{!! route('logout') !!}"
          class="dropdown-item"
          onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
          Logout
      </a>
      <form method="POST"
          action="{{ route('logout') }}"
          accept-charset="UTF-8"
          id="logout-form"
          style="display:none;"
      >
          {{ csrf_field () }}
      </form>
  @endif
  
sh
php artisan impersonator:publish --config
sh
php artisan impersonator:publish --views