当前位置:网站首页>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 .
边栏推荐
- How can Plato obtain premium income through elephant swap in a bear market?
- Leetcode60. permutation sequence
- CMake 基础学习
- SAP temporary tablespace error handling
- 【C】 Drink soda and find a single dog
- Network traffic monitoring tool iftop
- JS advanced ES6 ~ es13 new features
- Real time data warehouse: meituan's implementation of real-time data warehouse construction based on Flink
- Yolov5 learning notes (I) -- principle overview
- Servlet operation principle_ API details_ Advanced path of request response construction (servlet_2)
猜你喜欢

跳表的原理

Servlet运行原理_API详解_请求响应构造进阶之路(Servlet_2)

ZABBIX 5.0 uses its own redis template for monitoring

#{}和${}的区别

Network traffic monitoring tool iftop

动态规划问题(六)

Leetcode60. permutation sequence

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

Real time data warehouse: meituan's implementation of real-time data warehouse construction based on Flink

JS高级 之 ES6~ES13 新特性
随机推荐
Real time data warehouse: Didi's real-time data warehouse landing practice
JS advanced ES6 ~ es13 new features
Multimodal model sketch (1)
PIP image download
EN 1873 assembly accessories for roofing - plastic single roof lamps - CE certification
How can Plato obtain premium income through elephant swap in a bear market?
递归/回溯刷题(中)
【C】 Introduction and Simulation Implementation of ATOI and offsetof
"Method not allowed", 405 problem analysis and solution
1-7 solve the problem of this pointing of methods in classes
PHP poster QR code synthesis
centos7安装mysql8
IDEA2021.2安装与配置(持续更新)
Servlet运行原理_API详解_请求响应构造进阶之路(Servlet_2)
VS2005 accesses the setting method "recommended collection" of vss2005 through sourceoffsite
Concurrency in go
html+css+php+mysql实现注册+登录+修改密码(附完整代码)
【TA-霜狼_may-《百人计划》】图形3.6 纹理压缩——包体瘦身术
[TA frost wolf _may- "hundred people plan"] art 2.2 model basis
Yolov5 learning notes (I) -- principle overview