以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. elasticsearc 参考资料

    _source 和store http://stackoverflow.com/questions/18833899/in-elasticsearch-what-happens-if-i-set-st ...

  2. puthon-进程间通信-队列和管道

    ********进程间通信-队列和管道******** ****进程间通信-队列和管道 IPC(Inter-Process Communication) ****队列 **概念介绍 创建贡献的进程队列 ...

  3. setTimeout的异步传输机制

    setTimeout是异步的,在设置完setTimeout后,指定代码会在设定的时间后加入到任务队列,但并不是立即执行,js是单线程语言,所有的代码按顺序执行,即同步执行,同步执行的代码放在执行队列中 ...

  4. Linux上常用命令整理(二)—— paste

    上一篇整理了cat指令的几个基本常见用法,这次整理一下paste指令的基本用法. cat paste cut grep paste paste可以简单的理解为把两个文件的内容按列合并,与cat命令直接 ...

  5. 042 Trapping Rain Water 接雨水

    给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算下雨之后能接多少雨水.例如,输入 [0,1,0,2,1,0,1,3,2,1,2,1],返回 6. 详见:https://leetcode.c ...

  6. Ubuntu搭建WordPress-MySQL-Apache

    目标 技术博客www.xifarm.com有5年时间了. 原来在虚拟机/VPS上搭建,不过都是Windows系统下的. 最近突发奇想,试试迁移到Linux的Unbuntu下.说干就干,抽空用了大约3天 ...

  7. asp.net 多语言 在IIS7.5发布出现找不到资源文件

    我也遇到这个问题,纠结了半天, 最后把资源文件的属性改为:内容 就可以了. 见:http://q.cnblogs.com/q/60443/

  8. mysql查看各个表的大小

    information_schema 数据库,在该库中有一个 TABLES 表,这个表主要字段分别是: TABLE_SCHEMA : 数据库名 TABLE_NAME:表名 ENGINE:所使用的存储引 ...

  9. 关于锚点页内链接跳转出现问题(不响应,没有反应)的解决方法(ZT)

    我们知道,利用锚点可以实现页面链接跳转,也可以实现同一页面内的跳转功能. 例如:<a href="somepage.htm>某页面链接</a>  可以跳转链接到som ...

  10. Java热启动

    1.在项目中的pom.xml中添加 <dependency> <groupId>org.springframework.boot</groupId> <art ...