Code Monkey home page Code Monkey logo

permission's Introduction

permission

/* Navicat MySQL Data Transfer

Source Server : 192.168.1.186 Source Server Version : 50542 Source Host : 192.168.1.186:3306 Source Database : ruanwen

Target Server Type : MYSQL Target Server Version : 50542 File Encoding : 65001

Date: 2020-06-08 15:53:46 */

SET FOREIGN_KEY_CHECKS=0;


-- Table structure for model_has_permissions


DROP TABLE IF EXISTS model_has_permissions; CREATE TABLE model_has_permissions ( permission_id bigint(20) unsigned NOT NULL, model_type varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL, model_id bigint(20) unsigned NOT NULL, PRIMARY KEY (permission_id,model_id,model_type), KEY model_has_permissions_model_id_model_type_index (model_id,model_type) USING BTREE ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- Table structure for model_has_roles


DROP TABLE IF EXISTS model_has_roles; CREATE TABLE model_has_roles ( role_id bigint(20) unsigned NOT NULL, model_type varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL, model_id bigint(20) unsigned NOT NULL, PRIMARY KEY (role_id,model_id,model_type), KEY model_has_roles_model_id_model_type_index (model_id,model_type) USING BTREE ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- Table structure for permissions


DROP TABLE IF EXISTS permissions; CREATE TABLE permissions ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, parent_id int(11) NOT NULL DEFAULT '0', name varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '接口地址', display_name varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '名称', url varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '页面路由', guard_name varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, sort smallint(6) NOT NULL DEFAULT '0' COMMENT '排序,数字越大越在前面', icon varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, created_time timestamp NULL DEFAULT NULL, updated_time timestamp NULL DEFAULT NULL, type tinyint(1) NOT NULL DEFAULT '0' COMMENT '0菜单,1按钮', PRIMARY KEY (id) ) ENGINE=MyISAM AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- Table structure for role_has_permissions


DROP TABLE IF EXISTS role_has_permissions; CREATE TABLE role_has_permissions ( permission_id bigint(20) unsigned NOT NULL, role_id bigint(20) unsigned NOT NULL, PRIMARY KEY (permission_id,role_id), KEY role_has_permissions_role_id_foreign (role_id) USING BTREE ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


-- Table structure for roles


DROP TABLE IF EXISTS roles; CREATE TABLE roles ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, name varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, description varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL, guard_name varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'web', create_time timestamp NULL DEFAULT NULL, update_time timestamp NULL DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM AUTO_INCREMENT=24 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

#安装方法

composer require wangcb/permission

#User模型类加

class User extend Model{ use HasRole; }

$res = $user->getAllPermissions(); //获取所有权限

$user->can('/auth/add');//判断是否有权限

$res = $user->getMenu(); //获取权限菜单树

$user->getRoles();//获取用户角色

$user->clearRole();//删除用户所有角色

$user->roles([1,2,3]);//给用户分配角色

permission's People

Contributors

wangcb avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.