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


PHP Role::with方法代碼示例

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


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

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if (\Auth::user()->roles[0]->can('menu-read')) {
         $items = $this->menus->with('roles')->where('parent_id', '=', '0')->orderBy('sort_order', 'ASC')->get();
         return \View::make('acl::admin.menus.index', ['items' => $items, 'title' => 'list']);
     }
     return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access'));
 }
開發者ID:meccado,項目名稱:acl-admin-control-panel,代碼行數:13,代碼來源:MenuController.php

示例2: getAllRoles

 /**
  * @param string $order_by
  * @param string $sort
  * @param bool $withPermissions
  * @return mixed
  */
 public function getAllRoles($order_by = 'id', $sort = 'asc', $withPermissions = false)
 {
     if ($withPermissions) {
         return Role::with('permissions')->orderBy($order_by, $sort)->get();
     }
     return Role::orderBy($order_by, $sort)->get();
 }
開發者ID:num3thod,項目名稱:laravel-5-boilerplate,代碼行數:13,代碼來源:EloquentRoleRepository.php

示例3: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $this->authorize('roles-edit');
     $role = Role::with('permissions')->findOrFail($id);
     $permissions = Permission::orderBy('display_name')->get();
     return view('roles.edit', compact('permissions', 'role'));
 }
開發者ID:guenthertheilen,項目名稱:laravel-boilerplate,代碼行數:13,代碼來源:RolesController.php

示例4: update_role

 public function update_role(Request $request)
 {
     /*
     Delete existing role
     */
     Role::where('id', $request->role_id_to_remove)->delete();
     if ($request->user_id) {
         /*
         Add new role/user
         */
         $role = new Role();
         $role->booking_id = $request->booking_id;
         $role->role_type_id = $request->role_type_id;
         $role->user_id = $request->user_id;
         $role->save();
         /*
         write to changes
         */
         $user_name = User::where('id', $request->user_id)->first()->name;
         $change = array('booking_id' => $request->booking_id, 'change_type_id' => 1, 'user_id' => Auth::user()->id, 'from' => null, 'to' => $user_name);
         Change::create($change);
         $newRole = Role::with('role_type', 'user')->where('id', $role->id)->first();
         return $newRole;
     }
     return;
 }
開發者ID:jedlicka82,項目名稱:transferpraha,代碼行數:26,代碼來源:ApiController.php

示例5: role

 public function role()
 {
     $roles = Role::with('perms')->get();
     $perms = Permission::orderBy('name')->get();
     $roles_json = $roles->toArray();
     $data = compact('roles', 'perms', 'roles_json');
     // dd($data);
     return view('user.role', $data);
 }
開發者ID:ibnoe,項目名稱:trustline,代碼行數:9,代碼來源:UserController.php

示例6: postGiveRolePermissions

 /**
  * Store given permissions to role.
  *
  * @param  \Illuminate\Http\Request  $request
  *
  * @return void
  */
 public function postGiveRolePermissions(Request $request)
 {
     $this->validate($request, ['role' => 'required', 'permissions' => 'required']);
     $role = Role::with('permissions')->whereName($request->role)->first();
     $role->permissions()->detach();
     foreach ($request->permissions as $permission_name) {
         $permission = Permission::whereName($permission_name)->first();
         $role->givePermissionTo($permission);
     }
     Session::flash('flash_message', 'Permission granted!');
     return redirect('admin/roles');
 }
開發者ID:appzcoder,項目名稱:laravel-admin,代碼行數:19,代碼來源:AdminController.php

示例7: postUserRolePermissions

 /**
  * Store given permissions to role.
  *
  * @param  \Illuminate\Http\Request  $request
  *
  * @return void
  */
 public function postUserRolePermissions(Request $request)
 {
     $this->validate($request, ['role' => 'required', 'permissions' => 'required']);
     $role = Role::with('permissions')->whereName($request->role)->first();
     $role->permissions()->detach();
     foreach ($request->permissions as $permission_name) {
         $permission = Permission::whereName($permission_name)->first();
         $role->assign($permission);
     }
     \Session::flash('flash_message', 'Permission granted!');
     return \Redirect::route('admin.assign-role-permissions', []);
 }
開發者ID:meccado,項目名稱:acl-admin-control-panel,代碼行數:19,代碼來源:AdminController.php

示例8: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $validator = Validator::make($request->all(), ['name' => 'required', 'display' => 'required'], ['name.required' => 'Nama Role tidak boleh kosong.', 'display.required' => 'Alias tidak boleh kosong.']);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     $role = Role::with('permissions')->find($id);
     $inPermission = $request->get('permissions') != "" ? $request->get('permissions') : [];
     $rolePermission = array_column($role->permissions->toArray(), 'id');
     if ($role->update($request->all())) {
         // for new permissions
         $newPermission = array_diff($inPermission, $rolePermission);
         if (count($newPermission)) {
             $role->addPermission($newPermission);
         }
         // for delete permissions
         $deletePermission = array_diff($rolePermission, $inPermission);
         if (count($deletePermission)) {
             $role->removePermission($deletePermission);
         }
         return redirect('/user/role')->with('succcess', 'Sukses ubah role.');
     }
     return redirect()->back()->withErrors(['failed' => 'Gagal ubah role.']);
 }
開發者ID:sopoisun,項目名稱:narotser-hadni-kodnop,代碼行數:31,代碼來源:RoleController.php

示例9: getEffectivePermission

 public function getEffectivePermission()
 {
     if ($this->effectivePermission != null) {
         return $this->effectivePermission;
     } else {
         $role = \App\Role::with('permission')->find($this->getRoleId());
         if ($role != null) {
             $this->effectivePermission = $role->permission;
         } else {
             $this->effectivePermission = array();
         }
         return $this->effectivePermission;
     }
 }
開發者ID:deryrahma,項目名稱:dokternet,代碼行數:14,代碼來源:User.php

示例10: getStaff

 public function getStaff()
 {
     $staff = [];
     $roles = Role::with('users')->where('board_uri', $this->board_uri)->get();
     $roles = [];
     foreach ($this->roles as $role) {
         foreach ($role->users as $user) {
             $staff[$user->user_id] = $user;
             if (!isset($roles[$user->user_id])) {
                 $roles[$user->user_id] = [];
             }
             $roles[$user->user_id][] = $role;
         }
     }
     foreach ($roles as $user_id => $role) {
         $staff[$user_id]->setRelation('roles', collect($role));
     }
     return $staff;
 }
開發者ID:ZiRo-,項目名稱:infinity-next,代碼行數:19,代碼來源:Board.php

示例11: getStaff

 public function getStaff()
 {
     $staff = [];
     $roles = Role::with('users')->where('board_uri', $this->board_uri)->get();
     foreach ($this->roles as $role) {
         foreach ($role->users as $user) {
             $staff[$user->user_id] = $user;
         }
     }
     return $staff;
 }
開發者ID:nitogel,項目名稱:infinity-next,代碼行數:11,代碼來源:Board.php

示例12: index

 public function index()
 {
     $roles = Role::with('permissions')->get();
     return view('admin.roles.index', compact('roles'));
 }
開發者ID:wilderguzman,項目名稱:lugrawibe,代碼行數:5,代碼來源:RolesController.php

示例13: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\View\View
  */
 public function index()
 {
     $users = $this->users->with('roles')->get();
     return \View::make('admin.users.index', ['users' => $users, 'title' => 'list']);
 }
開發者ID:meccado,項目名稱:acl-admin-control-panel,代碼行數:10,代碼來源:UserController.php

示例14: index

 /**
  * Index
  */
 public function index()
 {
     return Role::with('permissions')->get();
 }
開發者ID:goatatwork,項目名稱:access2,代碼行數:7,代碼來源:RolesApiController.php

示例15: getRoles

 public function getRoles()
 {
     return Role::with('users')->get();
 }
開發者ID:imladrisol,項目名稱:onlineExam,代碼行數:4,代碼來源:AuthServiceProvider.php


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