定制 carving-i-t/laravel-user-roles 二次开发

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

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

carving-i-t/laravel-user-roles

最新稳定版本:v1.0.0

Composer 安装命令:

composer require carving-i-t/laravel-user-roles

包简介

Composer package for user roles in a Laravel project

README 文档

README

Composer package for user roles in a Laravel project.

Installation

composer require carving-i-t/laravel-user-roles 

php artisan vendor:publish --provider="CarvingIT\LaravelUserRoles\LaravelUserRolesServiceProvider" 

php artisan migrate

Running the role seeder (optional)

php artisan db:seed --class=RoleSeeder

Usage

In your User model, use the trait - LaravelUserRoles and then your user model can have following methods.

use CarvingIT\LaravelUserRoles\App\Traits\LaravelUserRoles;

class User extends Authenticatable{
    use LaravelUserRoles;

    .
    .
}

In your code elsewhere in your app -

//assign roles 
$user->assignRoles(['admin','staff']);
//unassign roles 
$user->unassignRoles(['admin']);

// check if your has a role
// returns true or false
$user->hasRole('admin'); 

// get all roles of a user

$roles = $user->roles(); // remember to use the parentheses

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-07