| Package Data | |
|---|---|
| Maintainer Username: | mikebronner |
| Maintainer Contact: | hello@genealabs.com (GeneaLabs, LLC) |
| Package Create Date: | 2017-05-09 |
| Package Last Update: | 2023-05-20 |
| Home Page: | |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-10-18 15:03:42 |
| Package Statistics | |
|---|---|
| Total Downloads: | 190,554 |
| Monthly Downloads: | 7,022 |
| Daily Downloads: | 194 |
| Total Stars: | 61 |
| Total Watchers: | 1 |
| Total Forks: | 7 |
| Total Open Issues: | 1 |
If you are using Larvel 5.4, please switch to the laravel-5.4 branch and follow the instructions there.
composer require genealabs/laravel-impersonator
This package will be auto-loaded by Laravel 5.5, it is not necessary to register any service providers or aliases for this package.
genealabs-laravel-impersonator.layout: master blade layout view for your application (default layouts.app).genealabs-laravel-impersonator.content-section: name of content section in master layout blade view (default content).genealabs-laravel-impersonator.user-model: user model of your application (default config('auth.providers.users.model')).If you need to customize these settings:
php artisan impersonator:publish --config
GeneaLabs\LaravelImpersonator\Traits\Impersonatable to your user model.public function getCanImpersonateAttribute() : bool that determines if a given user can impersonate other users.public function getCanBeImpersonatedAttribute() : bool that determines if a given user can be impersonated.route('impersonatees.index') to view a list of all impersonatable users.
You could add something like the following to your menu:@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
php artisan impersonator:publish --views
In large part prodded and inspired by LaraCasts' tutorial: https://laracasts.com/series/how-do-i/episodes/17. Thank you @JeffreyWay!