nckg / laravel-impersonate
Easily impersonate any user in a Laravel Application
Installs: 27 989
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: ^7.2|^8.0
Requires (Dev)
- illuminate/support: ^8.0
- mockery/mockery: ^1.4.2
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^8.4|^9.0
This package is auto-updated.
Last update: 2024-11-21 19:19:29 UTC
README
Introduction
Easily impersonate any user in your Laravel Application
Installation
You can install the package via composer:
composer require nckg/laravel-impersonate
Add following code to your user model:
class User { use \Nckg\Impersonate\Traits\CanImpersonate; }
Add following code to your routes file:
Route::get('users/{id}/impersonate', function ($id) { \Auth::user()->setImpersonating($id); return redirect()->back(); }); Route::get('users/stop-impersonate', function () { \Auth::user()->stopImpersonating(); return redirect()->back(); });
If you are using Laravel you can add the middleware to your middleware providers
// app/Http/Kernel.php /** * The application's global HTTP middleware stack. * * @var array */ protected $middleware = [ ... \Nckg\Impersonate\Impersonate::class, ];
Testing
composer test
License
The MIT License (MIT).