当前位置: 首页>>代码示例>>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;未经允许,请勿转载。