confrariaweb/laravel-user

laravel 完整用户包

dev-master 2023-06-07 04:16 UTC

This package is not auto-updated.

Last update: 2024-09-26 09:22:42 UTC


README

laravel 完整用户包。

安装

在控制台中,使用以下命令

composer require confrariaweb/laravel-user  

发布所需文件

php artisan vendor:publish --tag=public --force  
php artisan vendor:publish --tag=config --force 
php artisan config:cache 

然后使用 artisan migrate 创建表

php artisan migrate  

在 App\Models\User 类中,按以下方式包含 trait "ConfrariaWeb\User\Traits\UserTrait";
同时也在 fillable 变量中包含值;

<?php  
  
namespace  App;  
use ConfrariaWeb\User\Traits\UserTrait;  
use Illuminate\Contracts\Auth\MustVerifyEmail;  
use Illuminate\Foundation\Auth\User  as Authenticatable;  
use Illuminate\Notifications\Notifiable;  
  
class  User  extends Authenticatable  
{  
use  Notifiable;  
use  UserTrait;  
/**  
* The attributes that are mass assignable.  
*  
* @var  array  
*/  
  
protected $fillable = ['name', 'email', 'password', 'status', 'settings',  'options', 'account_id'
];  
  
/**  
* The attributes that should be hidden for arrays.  
*  
* @var  array  
*/  
protected $hidden = ['password', 'remember_token',  
];  
  
/**  
* The attributes that should be cast to native types.  
*  
* @var  array  
*/  
  
protected $casts = ['email_verified_at' => 'datetime',  
];  
  
}  

如果使用 laravel cw 账户包,则只将 "account_id" 的值包含在数组中

##检查包
要验证包是否正确安装,请使用以下 artisan 命令

php artisan user:check-package  

权限控制

  • admin.users.index = 查看用户
  • admin.users.edit = 编辑用户
  • admin.users.show = 查看特定用户
  • admin.users.destroy = 删除用户

许可证

Laravel 框架是开源软件,根据 MIT 许可证 许可。