laracomponents/impersonation
Composer 安装命令:
composer require laracomponents/impersonation
包简介
Impersonating user for Laravel application.
README 文档
README
Introduction
Impersonating user for Laravel application.
Installation
You can install this package via composer using this command:
composer require laracomponents/impersonation
Next, you must add the Impersonable trait to the user model:
use LaraComponents\Impersonation\Traits\Impersonable; class User { use Impersonable; ... /** * Optional method * Default return the "impersonate_id" **/ public function getImpersonatingKey() { return 'your session key here'; } }
Open App/Http/Kernal.php and add middleware to web middleware group:
protected $middlewareGroups = [ 'web' => [ ... \LaraComponents\Impersonation\Middleware\CheckForImpersonating::class, ], ... ];
And finally you should add a routes to routes/web.php. Example:
Route::get('users/{id}/impersonate', function ($id) { $user = \App\User::findOrFail($id); if(! $user->isImpersonating()) { $user->impersonate(); } return redirect('/'); }); Route::get('users/unimpersonate', function () { $user = \Auth::user(); if($user->isImpersonating()) { $user->unimpersonate(); } return redirect('/'); });
Testing
You can run the tests with:
vendor/bin/phpunit
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 1.04k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-01-26