承接 merodiro/simple-roles 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

merodiro/simple-roles

Composer 安装命令:

composer require merodiro/simple-roles

包简介

Simple laravel roles

README 文档

README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

SimpleRoles is a simple way to have roles in your laravel projects.

preview

Installation

Via Composer

$ composer require merodiro/simple-roles

Run the command to publish the package migration

php artisan vendor:publish --provider="Merodiro\SimpleRoles\SimpleRolesServiceProvider"

Migrate database

It assumes that users are in the users table, if not you can change the config file

php artisan migrate

add middleware in app/Http/Kernel.php

protected $routeMiddleware = [
    ...
    'role'      => \Merodiro\SimpleRoles\Middleware\RoleMiddleware::class,        
];

Usage

add roles to roles array in simple-roles config file first

Set Role

$user->setRole('admin');

Remove Role

$user->removeRole();

Has Role

if($user->hasRole('admin')){
    // do something
}

Blade Templates

to show content to admins only

@role('admin')
    <h3>this is visible to admins only</h3>
@endrole

to show different content to admins and non-admins users

@role('admin')
    <h3>this is visible to admins only</h3>
@else
    <h3>this is visible to non admins only</h3>
@endrole

middleware

you can use middleware to limit accessing a certain route to admins only

Route::get('/admin', function () {
    ...
})->middleware('role:admin');

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security-related issues, please email merodiro@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固