本文整理汇总了PHP中app\models\Permission::roles方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::roles方法的具体用法?PHP Permission::roles怎么用?PHP Permission::roles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Permission
的用法示例。
在下文中一共展示了Permission::roles方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tableRoles
/**
* Returns a new table of all roles that have the specified permission.
*
* @param Permission $permission
*
* @return \Orchestra\Contracts\Html\Builder
*/
public function tableRoles(Permission $permission)
{
$roles = $permission->roles()->with('users');
return $this->table->of('permissions.roles', function (TableGrid $table) use($permission, $roles) {
$table->with($roles)->paginate(10);
$table->column('label', function (Column $column) {
$column->value = function (Role $role) {
return link_to_route('admin.roles.show', $role->label, [$role->id]);
};
});
$table->column('name', function (Column $column) {
// We'll remove this column when
// viewing on smaller screens.
$column->headers = ['class' => 'hidden-xs'];
$column->attributes(function () {
return ['class' => 'hidden-xs'];
});
});
$table->column('users', function (Column $column) {
$column->value = function (Role $role) {
return $role->users->count();
};
});
$table->column('remove', function (Column $column) use($permission) {
$column->value = function (Role $role) use($permission) {
return link_to_route('admin.permissions.roles.destroy', 'Remove', [$permission->id, $role->id], ['class' => 'btn btn-xs btn-danger', 'data-post' => 'DELETE', 'data-title' => 'Are you sure?', 'data-message' => 'Are you sure you want to remove this permission from this role?']);
};
});
});
}