以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. jquery jtemplates.js模板渲染引擎的详细用法第三篇

    jquery jtemplates.js模板渲染引擎的详细用法第三篇 <span style="font-family:Microsoft YaHei;font-size:14px;& ...

  2. DotNetAnywhere

    DotNetAnywhere:可供选择的 .NET 运行时   原文 : DotNetAnywhere: An Alternative .NET Runtime作者 : Matt Warren译者 : ...

  3. 在写fegin客户端的时候无法继承接口

    仔细查看fegin是不是写成类了,要接口才行

  4. 浅谈C#解析网页

    最近做了一个项目,要求获取各大主流网页上的关键信息,本人以前了解过网页爬虫的知识,所以想到了网页爬虫了实现功能 第一次尝试: 采用webclient获取远程网页的内容,然后采用正则表达式进行过滤 但, ...

  5. C# 操作 sqlite

    1.下载sqlite:http://system.data.sqlite.org/downloads/1.0.94.0/sqlite-netFx20-setup-bundle-x86-2005-1.0 ...

  6. css3相关样式

    1.渐变 1.1 线性渐变(Linear Gradients)- 向下/向上/向左/向右/对角方向 background: linear-gradient(direction, color-stop1 ...

  7. css:hover伪类的使用

    :hover的使用,即当鼠标指针移入元素时,所做出的样式设置 示例一 <!DOCTYPE html> <html lang="en"> <head&g ...

  8. 从零开始的Lua宅[1]:编译Lua解释器

    Lua是一门神奇的脚本语言,游戏宅必备,懒人必备.Lua差多不是学起来用起来最简单的语言了,以至于简单到自身就是文档,自身就是配置文件.但是Lua的运行效率却是众多脚本中非常高的,据说仅次于V8爹下的 ...

  9. SpringMVC+Thymeleaf 简单使用

    一.简介 1.Thymeleaf 在有网络和无网络的环境下皆可运行,而且完全不需启动WEB应用,即它可以让美工在浏览器查看页面的静态效果,也可以让程序员在服务器查看带数据的动态页面效果.浏览器解释 h ...

  10. 使用PM2搭建在线vue.js开发环境(以守护进程方式热启动)

    项目以vue.js+layUI的作为前端开发技术栈,需要有一个在线的环境供项目成员实时查看效果,总不能每次都webpack打包发布后才能看到效果吧!刚开始就简单使用npm run dev命令热启动,但 ...