当前位置:网站首页>Laravel permission control
Laravel permission control
2022-07-29 00:18:00 【Ningmujun】
Add roles to the user table id, According to the character id Get user role , If it is a role, there is no need to create an intermediate table , Otherwise, you need to create an intermediate table .
According to the character id Get the role owned by the user , Get the permissions of the role according to the Chinese table of roles and permissions id, According to authority id Get the permission range of the user ,
$node_id = role_node::where('role_id', $role['id'])->get()->toArray(); $res = [];
foreach ($node_id as $v) {
$res[] = node::where('id', $v['node_id'])->first()->toArray();
}What we got here $res It is the user permissions queried , Deposit in session in , Then read the current permissions of the user in the middleware ,

This is the user permission obtained
Read the user's permission in the display homepage , Use recursion or three-level linkage , What you read is before you get it and then put it in session Authority
$res = Cache::get('auths');
$rbac = rbac::data($res);
return view('index', ['list' => $rbac]);recursive :
public static function data($data,$pid=0)
{
$res=[];
foreach ($data as $v){
if ($v['pid']==$pid){
$res[$v['id']]=$v;
$res[$v['id']]['son']=self::data($data,$v['id']);
}
}
return $res;
}Then display the obtained permissions on the home page .
边栏推荐
- Develop effective Tao spell
- Android studio连接MySQL并完成简单的登录注册功能
- Where is sandbox's confidence in rejecting meta's acquisition of meta universe leader sand?
- 跳表的原理
- Introduction and solution of common security vulnerabilities in web system CSRF attack
- 1-8 props的基础使用
- EN 1873 assembly accessories for roofing - plastic single roof lamps - CE certification
- IDEA报错Error running ‘Application‘ Command line is too long解决方案
- Detailed explanation of the usage of exists in MySQL
- Type 1-5 components
猜你喜欢

Leetcode63. Different paths II

动态规划问题(七)

Advanced area of attack and defense world web masters -baby Web

Using recursion and chain header interpolation to realize the group turnover of linked lists -- leetcode25 K group turnover linked lists

【C】 Replace spaces and realize binary parity bit exchange of integers by macros

Create AP hotspots for imx6 development board QT system based on rtl8723 cross compile iptables

熊市下PLATO如何通过Elephant Swap,获得溢价收益?

feign调用不通问题,JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r

Linux之yum安装MySQL

【微服务~Nacos】Nacos服务提供者和服务消费者
随机推荐
SQL实现将多行记录合并成一行
CV target detection model sketch (2)
Using recursion and chain header interpolation to realize the group turnover of linked lists -- leetcode25 K group turnover linked lists
2022网络安全学习路线 非常详细 推荐学习
Do like and in indexes in MySQL go
【MySQL 8】Generated Invisible Primary Keys(GIPK)
【微服务】Nacos集群搭建以及加载文件配置
Visual full link log tracking
Intelligent trash can (VII) -- Introduction and use of sg90 steering gear (Pico implementation of raspberry pie)
Detailed explanation of the usage of exists in MySQL
IDEA报错Error running ‘Application‘ Command line is too long解决方案
Android studio连接MySQL并完成简单的登录注册功能
How NAT configures address translation
动态规划问题(六)
JS advanced ES6 ~ es13 new features
Where is sandbox's confidence in rejecting meta's acquisition of meta universe leader sand?
Samsung asset management (Hong Kong) launched yuancosmos ETF to focus on investing in the future tuyere track
SAP temporary tablespace error handling
Build SSM project with JSP as view parser
DoIP测试开发实践