hapidjus / laravel-impersonate-ui
404labfr/laravel-impersonate 的 UI
1.7
2023-04-18 21:35 UTC
Requires
- php: >=7.1.3
- lab404/laravel-impersonate: ~1.7
- laravel/framework: ^7.0|^8.0|^9.0|^10.0
Requires (Dev)
- mockery/mockery: ^1.0
- phpunit/phpunit: ^7.0|^8.0|^9.0||^10.0
README
Laravel Impersonate UI
Laravel Impersonate UI 是一个 Laravel 扩展包,它为使用 https://github.com/404labfr/laravel-impersonate 时的用户模拟提供了一个易于使用的 UI。
要求
- Laravel >= 6.1
- PHP >= 7.1
安装
- 使用 Composer 需要 laravel-impersonate-ui
composer require hapidjus/laravel-impersonate-ui
- 将特性
Lab404\Impersonate\Models\Impersonate
添加到您的 User 模型中。
<?php namespace App; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Lab404\Impersonate\Models\Impersonate; class User extends Authenticatable { use Notifiable, Impersonate; }
配置
要发布配置和 blade 文件,请使用
php artisan vendor:publish --provider="Hapidjus\ImpersonateUI\ImpersonateUiServiceProvider"
添加 --tag=config
或 --tag=view
以仅发布配置或 blade 文件。
这是配置文件的内容
return [ /** * Enable Laravel Impersonate UI * * Laravel Impersonate UI is enabled by default when in debug * */ 'enabled' => env('APP_DEBUG',false), /** * Users allowed to impersonate * * Array of user emails, i.e ['admin@example.com'] or null for all * */ 'users_allowed_to_impersonate' => ['admin@example.com'], /** * Position of icon. * * Supported: "bottom-right", "bottom-left", "top-left", "top-right" * */ 'icon_position' => 'bottom-right', /** * Show Impersonate button. * * Trying to save some clicks? * Then this is the option for you! Select a user and BOOM - * form submitted - user impersonated. No need to click any * pesky buttons. * */ 'show_button' => true, /** * Globally include laravel-impersonate-ui. * * Or use this view: @include('impersonate-ui::impersonate-ui') * Note: If you choose to include the partials view you need to add * a check to test if the current users is allowed * to impersonate */ 'global_include' => true, /** * The URI/Route to redirect after taking an impersonation. * * Use 'back' to redirect to the previous page * */ 'take_redirect_to' => 'back', /** * The URI/Route to redirect after leaving an impersonation. * * Use 'back' to redirect to the previous page * */ 'leave_redirect_to' => 'back', /** * Only allow these users to be impersonated * * Array of user IDs or null for all * */ 'users_only' => null, /** * Exlude these users from beeing impersonated * * Array of user IDs or null for none * */ 'users_exclude' => null, ];
部分视图
您可以使用部分视图将 Impersonate UI 包含在任何您想要的页面上。注意:如果您选择包含部分视图,则需要添加一个检查以测试当前用户是否有权模拟。
@include('impersonate-ui::impersonate-ui')
享受模拟的乐趣。
请勿在生产环境中使用!