當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。