當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Permission::roles方法代碼示例

本文整理匯總了PHP中app\Permission::roles方法的典型用法代碼示例。如果您正苦於以下問題:PHP Permission::roles方法的具體用法?PHP Permission::roles怎麽用?PHP Permission::roles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Permission的用法示例。


在下文中一共展示了Permission::roles方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: store

 /**
  * Method for stroring a new permission in the database.
  *
  * @param PermissionRequest $request
  * @return mixed
  */
 public function store(PermissionRequest $request)
 {
     $permission = new Permission($request->all());
     $permission->save();
     if (is_null($request->get('roles'))) {
         $permission->roles()->sync([]);
     } else {
         $permission->roles()->sync($request->get('roles'));
     }
     $routes = $request->get('routes');
     foreach ($routes as $route) {
         $permission->routes()->create(['route' => $route]);
     }
     return redirect(route('rbac.permissions.index'))->withSuccess('You have successfully created a new permission.');
 }
開發者ID:JimiOhrid,項目名稱:shopStore,代碼行數:21,代碼來源:PermissionsController.php

示例2: seedDataSource

 /**
  * Seed Data Source
  *
  * @author SL
  * @return void
  */
 protected function seedDataSource()
 {
     Model::unguard();
     $permission = new \App\Permission();
     $permission->name = 'applications-merchant-payments';
     $permission->display_name = 'Merchant Payments';
     $permission->description = 'merchant payments';
     $permission->save();
     $roles = ['manager', 'su', 'administrator'];
     foreach ($roles as $roleName) {
         try {
             $role = \App\Role::where('name', '=', $roleName)->first();
             $permission->roles()->attach($role->id);
         } catch (Exception $e) {
         }
     }
     $permission->save();
     Model::reguard();
 }
開發者ID:paybreak,項目名稱:basket,代碼行數:25,代碼來源:PermissionSeeder.php

示例3: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  App\Permission $permission
  * @return Response
  */
 public function edit($permission)
 {
     $current_roles = array_pluck($permission->roles()->get(['roles.id'])->toArray(), 'id');
     return view('templates.' . \Config::get('webpanel.template') . 'webpanel.panel.permissions.edit', compact('permission', 'current_roles'));
 }
開發者ID:brucewu16899,項目名稱:WebPanel-Core,代碼行數:11,代碼來源:PermissionsController.php


注:本文中的app\Permission::roles方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。