alextigaer / team-auth
为 Laravel 5.* 设计的简单多认证包
1.0.1
2018-06-15 13:57 UTC
Requires
- laravel/framework: 5.*
This package is not auto-updated.
Last update: 2024-09-29 05:42:02 UTC
README
为 Laravel 5.5/6 设计的简单多认证包
目录
安装
composer require alextigaer/team-auth
基本用法
要创建一个新角色,只需运行以下命令
php artisan team-auth:create RoleName
此命令将
- 在 App\Http\Controllers\RoleName 目录下创建 5 个控制器
- ForgotPasswordController
- LoginController
- RegisterController
- ResetPasswordController
- RoleNameController
- 在 resources\views\role_name 目录下创建 5 个(如果缺少 layouts\app.blade.php 文件则加 1)视图
- passwords\email.blade.php
- passwords\reset.blade.php
- dashboard.blade.php
- login.blade.php
- register.blade.php
- 在 models 目录下创建 RoleName 的模型
- 编辑 config\auth.php 文件以添加角色的守卫、提供者和密码重置
- 创建 2 个迁移
- create_role_names_table
- create_role_names_password_resets_table
- 创建 RoleNameSeeder 并更新 DatabaseSeeder 以调用生成的 seeder
- 编辑 routes\web.php 文件以添加角色的路由
选项
如果您想,可以使用以下选项来自定义创建
--r (默认=y)
此选项允许选择用户是否能够注册此角色。选择 'n' 值,则不会创建 RegisterController 文件和注册 blade 文件,也不会将注册路由添加到 routes\web 文件中。
可能的值:y (默认),n
描述
{--r=y : Choose if users can register to this role, or not [y/n]}
用法
// Create the role excluding the possibility to register php artisan team-auth:create RoleName --r=n
--controllers (默认=y)
此选项允许选择是否应创建控制器。
可能的值:y (默认),n
描述
{--controllers=y : Choose whether to create controllers, or not [y/n]}
用法
// Create the role without creating the controllers php artisan team-auth:create RoleName --controllers=n
--views (默认=y)
此选项允许选择是否应创建视图。
可能的值:y (默认),n
描述
{--views=y : Choose whether to create views, or not [y/n]}
用法
// Create the role without creating the views php artisan team-auth:create RoleName --views=n
--model (默认=y)
此选项允许选择是否应创建模型。
可能的值:y (默认),n
描述
{--model=y : Choose whether to create model, or not [y/n]}
用法
// Create the role without creating the model php artisan team-auth:create RoleName --model=n
--config-auth (默认=y)
此选项允许选择是否应编辑 config\auth 文件。
可能的值:y (默认),n
描述
{--config-auth=y : Choose whether to edit config\auth file, or not [y/n]}
用法
// Create the role without editing the config\auth file
php artisan team-auth:create RoleName --config-auth=n
--migrations (默认=y)
此选项允许选择是否应创建迁移。
可能的值:y (默认),n
描述
{--migrations=y : Choose whether to create migrations, or not [y/n]}
用法
// Create the role without creating the migrations php artisan team-auth:create RoleName --migrations=n
--m (默认=n)
此选项允许选择是否应运行迁移。
可能的值:y,n (默认)
描述
{--m=y : Choose whether to run the command migrate, or not [y/n]}
用法
// Create the role running the migrate command
php artisan team-auth:create RoleName --m=y
--seeder (默认=y)
此选项允许选择是否应创建 seeder。
可能的值:y (默认),n
描述
{--seeder=y : Choose whether to create seeder, or not [y/n]}
用法
// Create the role without creating the seeder php artisan team-auth:create RoleName --seeder=n
--s (默认=n)
此选项允许选择是否应运行 db:seed。
可能的值:y,n (默认)
描述
{--s=y : Choose whether to run the command db:seed, or not [y/n]}
用法
// Create the role running the db:seed command
php artisan team-auth:create RoleName --s=y
--routes-web (默认=y)
此选项允许选择是否应编辑 routes\web 文件。
可能的值:y (默认),n
描述
{--routes-web=y : Choose whether to edit routes\web file, or not [y/n]}
用法
// Create the role without editing the routes\web file
php artisan team-auth:create RoleName --routes-web=n
配置
此包有其自己的配置文件。在该文件中,您将找到
- 指定模型位置的条目
- 选项的默认值。如果您通过命令行使用选项,则这些值将被覆盖
使用示例
- 创建一个名为 'Admin' 的角色,不创建 seeder 但运行迁移
php artisan team-auth:create Admin --m=y --seeder=n
- 创建一个名为'Mod'的角色,防止用户注册此角色
php artisan team-auth:create Mod --r=n
- 创建一个名为'SuperUser'的角色,仅创建模型
php artisan team-auth:create SuperUser --controllers=n --views=n --config-auth=n --migrations=n --seeder=n --routes-web=n
贡献
欢迎提出任何建议!使用拉取请求或联系我:)
许可
TeamAuth采用MIT许可。用爱制作,让我们一起分享吧!:)