当前位置:网站首页>Laravel RBAC laravel permission use
Laravel RBAC laravel permission use
2022-06-30 14:11:00 【Ebony feed feed Wayne yetun wyuwenmu Bian OSAS】
Catalog
a citation
Because of business needs need rbac To encode And then in packagist I found the package with the highest download volume , After that, I began to do some rough research Old habits , Put the official documents first ( The document is in pure English A little unfriendly
Official documents :Introduction | laravel-permission | Spatie
Github Address :GitHub - spatie/laravel-permission: Associate users with roles and permissions
install
composer require spatie/laravel-permissionAfter pulling the bag Start publishing
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
If you need the concept of user groups Can be in config/permission There's a teams Put the back of false Change it to true Then you can use the group .
Then start table migration
php artisan migrateThen you can generate tables . Pay attention to the table structure and data
Basic usage
Can be Spatie\Permission\Traits\HasRoles Add features in the model
Use... In the model layer
use HasRoles;This package allows users to associate permissions and roles , Each role is associated with multiple permissions
Create role create permission You can use the following methods to create
$role = Role::create(['name' => 'writer']); // Create the role
$permission = Permission::create(['name' => 'edit articles']); // Create permissions Assign permissions
$role->givePermissionTo($permission);
$permission->assignRole($role);Synchronize multiple permissions into one role
$role->syncPermissions($permissions);
$permission->syncRoles($roles);You can use the following methods to remove permissions from a role
$role->revokePermissionTo($permission);
$permission->removeRole($role);That's all for simple usage
To be continued ......
边栏推荐
- 知识传播不能取代专业学习!
- 【系统分析师之路】第五章 复盘软件工程(软件过程改进)
- This article explains the concepts of typed array, arraybuffer, typedarray, DataView, etc
- Pytoch viewing model parameter quantity and calculation quantity
- Shell programming overview
- Lifting scanning tool
- Observable, reliable: the first shot of cloudops series Salon of cloud automation operation and maintenance
- Google Earth Engine(GEE)——GHSL:全球人类住区层,建成网格 1975-1990-2000-2015 (P2016) 数据集
- Pytorch查看模型参数量和计算量
- Problems in QT creator (additional unknown and error lines are listed in the debug output window)
猜你喜欢

Go language mutex lock

【刷题篇】避免洪水泛滥

Mysql database foundation: stored procedures and functions

Why does the folder appear open in another program

Race of golang

重磅:国产IDE发布,由阿里研发,完全开源!

MySQL access denied, opened as Administrator

Crypto questions

"Persistent diseases" that cannot be solved in IM application development

【科学文献计量】外文文献及中文文献关键词的挖掘与可视化
随机推荐
How to take the first step in digital transformation
Heavyweight: the domestic ide was released, developed by Alibaba, and is completely open source!
Lifting scanning tool
Impersonate server and client using message queuing
Deep understanding Net (2) kernel mode 3 Kernel mode construct mutex
Go sync. WaitGroup
Introduction to reverse commissioning - VA and RVA conversion in PE 04/07
Unity animator parameter
Jetpack compose for perfect screen fit
Flat shading with unity
Google Earth engine (GEE) - ghsl: global human settlements layer, built grid 1975-1990-2000-2015 (p2016) data set
[kali] Kali system, software update (with image source)
Cost forecast of PMP (BAC, EAC, etc)
There is no utf8 option for creating tables in Navicat database.
exlipse同时操作多行。比如同时在多行同列输入相同的文字
org.json.JSONObject对象转json,json新增元素,根据json的key获取值。以及list对象格式字符串转jsonArray
notepad正则删除关键词所在行
[scientific research data processing] [basic] category variable frequency analysis chart, numerical variable distribution chart and normality test (including lognormal)
Advanced usage of go language for loop break and continue
可观测,才可靠:云上自动化运维CloudOps系列沙龙 第一弹