定制 majebry/laravel6-userable 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

majebry/laravel6-userable

Composer 安装命令:

composer require majebry/laravel6-userable

包简介

Multiple User Type Models for Laravel 6

README 文档

README

This package transforms Laravel's User model to be an "abstract-like" model so that you can create as much separate userable (user-type) models as you wish with their auth controllers and a middleware by just running some command.

Installation

Use composer dependency manager to install this package.

composer require majebry/laravel6-userable

Usage

  1. publish migrations:
php artisan vendor:publish --provider="Majebry\LaravelUserable\UserableServiceProvider" --tag="migrations"
  1. Include Userable trait into your Laravel's User model
class User extends Authenticatable
{
    use \Majebry\LaravelUserable\Traits\Userable;
    //...
}

So, anytime you want to call user info for any userable model you can do Model::find($id)->userable

  1. Now, for example, if we want to generate a user-type called Customer, we run the following command
php artsian userable:make Customer

This command will generate a Customer model under app directory and a x_create_customers_table.php under database\migrations directory You can add the fields that you wish to that migration before running it

  1. In app/Http/Kernal.php, register the following middleware
protected $routeMiddleware = [
    // ...
    'userable-auth' => \Majebry\LaravelUserable\Http\Middleware\UserTypeMiddleware::class,
];

Now for example, if you want to protect a route to be only accessible for StoreAdmin, you can chain the Route with ->middleware('userable-auth:store-admin')

Contributing

...

Todo

  • Probably make the generator command also generates custom authentication actions(routes and controllers), middleware and/or views with the generator command.
  • Add tests
  • Making the UserTypeMiddleware supports multiple user-types
  • Hooking into on User/Userable Delete event?

License

MIT

统计信息

  • 总下载量: 49
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-12-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固