当前位置: 首页>>代码示例>>PHP>>正文


PHP Permission::get方法代码示例

本文整理汇总了PHP中app\models\Permission::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::get方法的具体用法?PHP Permission::get怎么用?PHP Permission::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Permission的用法示例。


在下文中一共展示了Permission::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: show

 public function show($id)
 {
     if (Auth::user()->can('read-role')) {
         $data['role'] = Role::find($id);
         $data['title'] = "Role \"" . $data['role']->display_name . "\"";
         $data['menu_actions'] = [Form::editItem(route('roles.edit', $id), 'Edit This Role', Auth::user()->can('update-role'))];
         $permissions = Permission::get();
         $permissions_in_role = Permission::whereHas('roles', function ($q) use($id) {
             $q->where('roles.id', $id);
         })->get();
         $counter = 0;
         foreach ($permissions as $permission) {
             $is_in_role = false;
             foreach ($permissions_in_role as $permission_in_role) {
                 if ($permission->id == $permission_in_role->id) {
                     $is_in_role = true;
                 }
             }
             $data['permissions'][$counter] = $permission;
             $data['permissions'][$counter]['is_in_role'] = $is_in_role;
             $counter++;
         }
         return view('roles/show', $data);
     } else {
         return redirect()->back()->withErrors(['Access denied to roles show page']);
     }
 }
开发者ID:pinkynrg,项目名称:convergence2.0,代码行数:27,代码来源:RolesController.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Role::create(['name' => 'Admin', 'display_name' => '超级管理员']);
     Role::create(['name' => 'Editor', 'display_name' => '编辑']);
     Role::create(['name' => 'Demo', 'display_name' => '演示']);
     Role::get()->each(function ($role) {
         if ($role->name === 'Admin') {
             $permissions = Permission::get()->pluck('id')->all();
             $role->perms()->sync($permissions);
         }
         if ($role->name === 'Editor') {
             $permissions = Permission::where('name', 'manage_contents')->first();
             $role->perms()->sync([$permissions->id]);
         }
     });
 }
开发者ID:axex,项目名称:kratos,代码行数:21,代码来源:RoleTableSeeder.php

示例3: assign_per_role

 public function assign_per_role()
 {
     $roles = Role::get(['id', 'name']);
     $permissions = Permission::get(['id', 'name']);
     return view('assign_per_role', compact('roles', 'permissions'));
 }
开发者ID:sushilcs111,项目名称:sourcesunlimited,代码行数:6,代码来源:PermissionsController.php

示例4: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $permission = Permission::get();
     return response()->json(["msg" => "Success", "items" => $permission], 200);
 }
开发者ID:whoOami,项目名称:potential-smd,代码行数:10,代码来源:PermissionController.php


注:本文中的app\models\Permission::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。