以Page为例讲解:

取消admin的roles下Pages的Browse Pages权限:

打开web.php文件,添加:

Route::get('pages', function(){
return view('pages');
});

创建文件pages.blade.php:

<?php $page = TCG\Voyager\Models\Page::first();?>

@can('browse', $page)

  You can browse pages

@endcan

Page的Model位置:

选中roles下Pages下的Browse的pages:

然后前端就可以输出了http://test.com/pages,显示效果:

然后我们页可以改为edit pages

文件pages.blade.php改为:

<?php $page = TCG\Voyager\Models\Page::first();?>

@can('ed'it, $page)

  You can edit pages

@else
You do not have access to edit pages
@endcan

权限设好啦,只需要在后台修改一下权限就可以实现想要的效果

如何我们只想browse pages,我们还可以这样写:

<?php $browsePages = Voyager::can('browse_pages'); ?>

@if($browsePages)

  You can browse pages

@else

  You cannot browse pages

@endif

Voyager的Roles和Pemissions的更多相关文章

  1. MongoDB的内置角色 Built-In Roles

    关于芒果的权限控制说白了就是定义 Role(角色) 来控制对数据库进行的操作(调用的方法比如查询方法find). 系统内置的Role分为 以下几大类: Database User Roles 这个是针 ...

  2. Apple Developer Program Roles Overview

    Apple Developer Program Roles Overview There are three roles that can be assigned to Apple Developer ...

  3. Show Roles Assigned to a Specific User

     Here is a query that I often use to lookup Roles assigned to a specific PeopleSoft user. At run tim ...

  4. Developers, do consider different user roles! - A bad experience with cron

    The Story: Last week, I found one of our embedded arm linux device  ran out of flash space( totally ...

  5. [Hive - LanguageManual] Create/Drop/Grant/Revoke Roles and Privileges / Show Use

    Create/Drop/Grant/Revoke Roles and Privileges Hive Default Authorization - Legacy Mode has informati ...

  6. Ansible系列(五):playbook应用和roles自动化批量安装示例

    html { font-family: sans-serif } body { margin: 0 } article,aside,details,figcaption,figure,footer,h ...

  7. IdentityServer4 指定角色授权(Authorize(Roles="admin"))

    1. 业务场景 IdentityServer4 授权配置Client中的AllowedScopes,设置的是具体的 API 站点名字,也就是使用方设置的ApiName,示例代码: //授权中心配置 n ...

  8. ansible roles

    roles 特点 目录结构清晰 重复调用相同的任务 目录结构相同 web - tasks - install.yml - copfile.yml - start.yml -  main.yml - t ...

  9. ansible基础-roles

    一 简介 注:本文demo使用ansible2.7稳定版 在我看来,role是task文件.变量文件.handlers文件的集合体,这个集合体的显著特点是:可移植性和可重复执行性. 实践中,通常我们以 ...

随机推荐

  1. Tomcat,Apache,JBoss的区别

    1.Apache是Http服务器,Tomcat是web服务器,JBoss是应用服务器. 2.Apache解析静态的html文件:Tomcat可解析jsp动态页面.也可充当servlet容器. 详细内容 ...

  2. Python多继承C3算法

    Python3 多继承的MRO算法选择.MRO(Method Resolution Order):方法解析顺序. Python3 只保留了C3算法! C3算法解析: 1.C3算法解析 C3算法:MRO ...

  3. Luogu P2522 [HAOI2011]Problem b 莫比乌斯反演

    设$f(d)=\sum_{i=1}^N\sum_{j=1}^M[gcd(i,j)==d],\\F(n)=\sum_{n|d}f(d)=\lfloor \frac{N}{n} \rfloor \lflo ...

  4. AtCoder Regular Contest 082 ABCD

    A #include<bits/stdc++.h> using namespace std; ]; int n,m; int main(){ cin>>n>>m; ...

  5. Git关于Tag操作

    Git关于tag的操作 记录下git关于 tag的操作 列出所有标签 git tag : 列出所有的 git tag -l 'v1.2.4.*' : 最后一位任意匹配 新建标签 git tag -a ...

  6. docker jetty启动时报错 failed setting default capabilities.

    docker 容器中jetty启动fail ,查看/var/log/jetty中的日志发现具体错误信息如下: failed setting default capabilities.set_caps( ...

  7. 过流监测芯片ADS720/723

    在电机应用领域经常需要用到过流监测和保护,allegro的ADS系列就可以很好实现.将芯片串接在电机之前,根据自己要保护的电流大小选择合适的量程,个根据自己ADC测量电压范围选择合适的灵敏度.这类芯片 ...

  8. SSIS-Dtsx包文件打开时一直验证

    把每个项的DelayValidation设置为true. 也可以直接改文件: 把文件里的 <DTS:Property DTS:Name="DelayValidation"&g ...

  9. ML.NET 示例:目录

    ML.NET 示例中文版:https://github.com/feiyun0112/machinelearning-samples.zh-cn 英文原版请访问:https://github.com/ ...

  10. 表单验证插件jquery.validate.js

    最常使用JavaScript的场合就是表单的验证,而jQuery作为一个优秀的JavaScript库,也提供了一个优秀的表单验证插件----Validation.Validation是历史最悠久的jQ ...