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


PHP Role::with方法代码示例

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


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

示例1: show

 /**
  * Displays the specified role.
  *
  * @return \Illuminate\View\View
  */
 public function show($id)
 {
     $this->authorize('admin.roles.show');
     $role = $this->role->with('users')->findOrFail($id);
     $users = $this->presenter->tableUsers($role);
     $formUsers = $this->presenter->formUsers($role);
     $permissions = $this->presenter->tablePermissions($role);
     $formPermissions = $this->presenter->formPermissions($role);
     return view('admin.roles.show', compact('role', 'users', 'formUsers', 'permissions', 'formPermissions'));
 }
开发者ID:stevebauman,项目名称:ithub,代码行数:15,代码来源:RoleController.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:aysenli,项目名称:laravel5-backend,代码行数:13,代码来源:RoleRepository.php

示例3: getAllRoles

 public function getAllRoles($relationships = null)
 {
     if (isset($relationships)) {
         return Role::with($relationships)->get();
     }
     return Role::all();
 }
开发者ID:gabwhite,项目名称:fsh,代码行数:7,代码来源:DataAccessLayer.php

示例4: postRegister

 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postRegister(Request $request)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     Auth::login($this->create($request->all()));
     $roleid = new RoleUser();
     $roleid->role_id = 3;
     $roleid->user_id = Auth::user()->id;
     $roleid->save();
     // Log::alert($roleid[0]);
     $permit = Role::with('perms')->where('id', $roleid->role_id)->get();
     //  Log::info($permit[0]->perms);
     // Log::alert(json_encode($child));
     $menus = [];
     foreach ($permit[0]->perms as $detail) {
         if ($detail->parent == '0') {
             $menu = array();
             foreach ($permit[0]->perms as $child) {
                 if ($child->parent == $detail->id) {
                     array_push($menu, $child);
                 }
             }
             $detail = array_add($detail, 'child', $menu);
             array_push($menus, $detail);
         }
     }
     //Log::info($menus);
     Session::set('menu', $menus);
     return redirect($this->redirectPath());
 }
开发者ID:alkindiisda,项目名称:laravel,代码行数:38,代码来源:RegistersUsers.php

示例5: getUserAuthList

 /**
  * 获取角色权限组和权限列表
  * @param $role_id
  * @return mixed
  */
 public static function getUserAuthList($role_id)
 {
     $authGroup = Role::with('roleGroup')->where('role_id', '=', $role_id)->first();
     $authList = AuthGroupRelaionship::getAuthGroupRelationshipByGroupLabel($authGroup->roleGroup->group_label);
     $data['authGroup'] = $authGroup->roleGroup;
     $data['authList'] = $authList;
     return $data;
 }
开发者ID:xinzou,项目名称:authority_management,代码行数:13,代码来源:Role.php

示例6: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if ($result = check_auth_to('JSLB_INDEX')) {
         return $result;
     }
     $site = Config::get('site');
     $data['roleList'] = Role::with('roleGroup')->paginate($site['page_size']);
     return view('admin.role.index', $data);
 }
开发者ID:xinzou,项目名称:authority_management,代码行数:14,代码来源:RoleController.php

示例7: postLogin

 /**
  * Handle a login request to the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postLogin(Request $request)
 {
     $this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required']);
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return $this->sendLockoutResponse($request);
     }
     if (Auth::attempt($this->getCredentials($request), $request->has('remember'))) {
         if ($throttles) {
             $this->clearLoginAttempts($request);
         }
         // Log::info(Auth::user()->hasRole('admin'));
         // Log::info(Auth::user()->can('ui_features'));
         $roleid = RoleUser::where('user_id', Auth::user()->id)->get();
         // Log::alert($roleid[0]);
         $permit = Role::with('perms')->where('id', $roleid[0]->role_id)->get();
         //  Log::info($permit[0]->perms);
         // Log::alert(json_encode($child));
         $menus = [];
         foreach ($permit[0]->perms as $detail) {
             if ($detail->parent == '0') {
                 $menu = array();
                 foreach ($permit[0]->perms as $child) {
                     if ($child->parent == $detail->id) {
                         array_push($menu, $child);
                     }
                 }
                 $detail = array_add($detail, 'child', $menu);
                 array_push($menus, $detail);
             }
         }
         //Log::info($menus);
         Session::set('menu', $menus);
         return redirect()->intended($this->redirectPath());
     }
     if ($throttles) {
         $this->incrementLoginAttempts($request);
     }
     return redirect($this->loginPath())->withInput($request->only($this->loginUsername(), 'remember'))->withErrors([$this->loginUsername() => $this->getFailedLoginMessage()]);
 }
开发者ID:alkindiisda,项目名称:laravel,代码行数:46,代码来源:AuthenticatesUsers.php

示例8: index

 public function index()
 {
     // Get all Role records for current page.
     $roles = Role::with('users')->paginate(25);
     return $this->getView()->shares('title', __d('users', 'Roles'))->with('roles', $roles);
 }
开发者ID:nova-framework,项目名称:app,代码行数:6,代码来源:Roles.php

示例9: index

 public function index()
 {
     // Get all Role records for current page - used with the Extended Auth Driver.
     $roles = Role::with('users')->paginate(25);
     return $this->getView()->shares('title', __('Roles'))->with('roles', $roles);
 }
开发者ID:nova-framework,项目名称:cms,代码行数:6,代码来源:Roles.php

示例10: manageableRolesForUser

 private function manageableRolesForUser()
 {
     $roles = $this->roleResultToList(Role::with('perms')->get());
     if (Entrust::can(PermissionNames::ManageGlobalPermissions())) {
         return $roles;
     }
     //Filter out global permissions
     $roles = array_filter($roles, function ($r) {
         $globalPerms = PermissionNames::AllGlobalPermissions();
         foreach ($r->perms as $p) {
             if (in_array($p->name, $globalPerms)) {
                 return false;
             }
         }
         return true;
     });
     $confPermNamePart = PermissionNames::normalizePermissionName(PermissionNames::ConferencePermissionManagement(1));
     $evtPermNamePart = PermissionNames::normalizePermissionName(PermissionNames::EventPermissionManagement(1));
     //Get the permissions this user has which are permissions management
     //permissions
     $currentPermManagement = Permission::whereHas("roles", function ($query) {
         $query->whereHas("users", function ($query) {
             //on Account table
             $query->where("id", Auth::user()->id);
         });
     })->where(function ($query) use($confPermNamePart, $evtPermNamePart) {
         $query->where('name', 'like', $confPermNamePart . '%');
         $query->orWhere('name', 'like', $evtPermNamePart . '%');
     })->get();
     $conferences = [];
     $events = [];
     foreach ($currentPermManagement as $perm) {
         if (PermissionNames::isConferencePermission($perm->name)) {
             $conferences[] = PermissionNames::extractPermissionData($perm->name)->idPart;
         } else {
             $events[] = PermissionNames::extractPermissionData($perm->name)->idPart;
         }
     }
     $ownedEvents = Event::whereIn('conferenceID', $conferences)->select('id')->get();
     $ownedEvents = array_map(function ($e) {
         return $e['id'];
     }, $ownedEvents->toArray());
     $events = array_merge($events, $ownedEvents);
     //Filter out permissions not associated with the conferences/events
     //this user can control.
     $roles = array_filter($roles, function ($r) use($events, $conferences) {
         foreach ($r->perms as $p) {
             if (PermissionNames::isConferencePermission($p->name)) {
                 $confId = PermissionNames::extractPermissionData($p->name)->idPart;
                 if (!in_array($confId, $conferences)) {
                     return false;
                 }
             } else {
                 if (PermissionNames::isEventPermission($p->name)) {
                     $evtId = PermissionNames::extractPermissionData($p->name)->idPart;
                     if (!in_array($evtId, $events)) {
                         return false;
                     }
                 }
             }
             return true;
         }
     });
     return $roles;
 }
开发者ID:a161527,项目名称:cs319-p2t5,代码行数:65,代码来源:PermissionsController.php

示例11: getShow

 public function getShow(Request $request, $id)
 {
     $includes = $this->getIncludes($request);
     $role = Role::with($includes)->findOrFail($id);
     return response()->json(['role' => $role]);
 }
开发者ID:fluentkit,项目名称:fluentkit,代码行数:6,代码来源:RolesController.php

示例12: getRoleAndPermissions

 public function getRoleAndPermissions($role_id)
 {
     return Role::with('permissions')->where('id', $role_id)->first();
 }
开发者ID:lufias,项目名称:L5admin,代码行数:4,代码来源:RoleRepository.php

示例13: getIndex

 public function getIndex()
 {
     $roles = Role::with('perms')->get();
     return $roles;
 }
开发者ID:bluesky777,项目名称:5myvc,代码行数:5,代码来源:RolesController.php

示例14: create

 public function create($id)
 {
     $user = User::with('role_users')->with('role_users.role_id')->with('role_users.permission_roles')->with('role_users.permission_roles.permissions')->find($id);
     $role = Role::with('permission_role')->with('permission_role.permissions')->with('permission_role.role_user')->with('permission_role.role_user.user')->get();
     return view('admin.user.addPermission', compact('user', 'role'));
 }
开发者ID:stillAssasin,项目名称:pedulijilbab,代码行数:6,代码来源:UserManagementController.php


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