当前位置:网站首页>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
- "Method not allowed", 405 problem analysis and solution
- Everything you have learned will come in handy at some point in your life (turn)
- Laptop external display
- MySQL安装配置教程(超级详细、保姆级)
- Leetcode 763. partition labels divide alphabetic intervals (medium)
- mysql中exists的用法详解
- curl (7) Failed connect to localhost8080; Connection refused
- CMake 基础学习
- Oracle超全SQL,细节狂魔
猜你喜欢

Control fillet stroke materialshapedrawable

Principle of meter skipping

Idea error running 'application' command line is too long solution

Idea2021.2 installation and configuration (continuous update)

Pycharm configuring the running environment

ZABBIX 5.0 uses its own redis template for monitoring

Interpretation of ISO 13400 (doip) standard

Leetcode63. Different paths II

Build SSM project with JSP as view parser

[TA frost wolf _may- "hundred people plan"] art 2.2 model basis
随机推荐
centos7安装mysql8
Opencv macro definition
Three years after graduation, write to you and me who may be confused [turn]
【C】 Drink soda and find a single dog
IDEA报错Error running ‘Application‘ Command line is too long解决方案
Oracle超全SQL,细节狂魔
Advanced area of attack and defense world web masters training www robots
Real time data warehouse: Netease strictly selects the practice of real-time data warehouse based on Flink
递归/回溯刷题(中)
Intelligent trash can (VII) -- Introduction and use of sg90 steering gear (Pico implementation of raspberry pie)
MySql中的like和in走不走索引
1-7 解决类中方法的this指向问题
Multimodal model sketch (1)
curl (7) Failed connect to localhost8080; Connection refused
laptop外接显示器
What is in word?:^ p
With this, your messages can't be monitored
[TA frost wolf \u may - "hundred people plan"] Figure 3.6 texture compression - inclusion slimming
Immutable x officially opens IMX token pledge detailed IMX pledge introduction optimistic about the development prospect of IMX
2022 network security learning route is very detailed, recommended Learning