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


PHP Role::all方法代码示例

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


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

示例1: roles

 public static function roles($type = null, $data = null)
 {
     if ($type and $data) {
         return Role::where($type, $data)->get();
     }
     return Role::all();
 }
开发者ID:ConsoleTVs,项目名称:Laralum,代码行数:7,代码来源:Laralum.php

示例2: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $users = User::with('roles')->get();
     $roles = Role::all();
     return view('rbac.user')->with(['users' => $users, 'roles' => $roles]);
     // return view('rbac.user');
 }
开发者ID:WangWeigao,项目名称:m1,代码行数:12,代码来源:RbacController.php

示例3: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $user = User::find($id);
     $roles = $user->roles()->get();
     $all_roles = Role::all();
     return view('pages.admin_pages.user')->with('user', $user)->with('roles', $roles)->with('all_roles', $all_roles);
 }
开发者ID:abreban,项目名称:RGU,代码行数:13,代码来源:UsersController.php

示例4: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     $role = Role::all();
     $user = User::find($id);
     return view('backend.pages.users.profile', array('user' => $user, 'role' => $role));
 }
开发者ID:nhunght,项目名称:mork_SmartOSC,代码行数:13,代码来源:UserController.php

示例5: roles

 public function roles()
 {
     if (!\Session::get('user')->is_admin()) {
         abort(401);
     }
     return view('roles/index', ['roles' => Role::all()]);
 }
开发者ID:genee-projects,项目名称:snail,代码行数:7,代码来源:RoleController.php

示例6: create

 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $mainItems = DB::table('menus')->where('is_main', 1)->get();
     // dd($mainItems);
     $roles = Role::all();
     return view('menu.create', ['roles' => $roles, 'mainItems' => $mainItems]);
 }
开发者ID:muschottkey,项目名称:bausbaus,代码行数:12,代码来源:MenuController.php

示例7: index

 public function index(Request $request)
 {
     //SE REGISTRA LA ACTIVIDAD EN LA BITACORA
     $this->binnacle("ENTRÓ A LA LISTA DE ROLES", $request);
     $roles = Role::all();
     return view('role.index', compact('roles'));
 }
开发者ID:cruni505,项目名称:prestomed,代码行数:7,代码来源:RoleController.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($user = $request->user()) {
         //判断是不是管理员
         $userRoles = Role::all();
         foreach ($userRoles as $r) {
             $roles[] = $r->name;
         }
         if (!$user->hasRole($roles)) {
             redirect()->guest('auth/login');
         }
         //创始人拥有所有权限
         if (!$user->hasRole('Founder')) {
             $can = Route::currentRouteName();
             //当前routeName  exp:user.test
             $res = $request->user()->can($can);
             if (!$res) {
                 return view('admin.noaccess');
             }
         }
     } else {
         return redirect()->guest('auth/login');
     }
     return $next($request);
 }
开发者ID:nutsdo,项目名称:mz-service,代码行数:32,代码来源:AccessControl.php

示例9: editRoles

 public function editRoles($userId = null)
 {
     if (is_null($userId)) {
         return editRoles(Auth::id());
     }
     //if you can't edit roles, abort.
     if (!Gate::allows('edit-roles')) {
         abort(403);
     }
     $user = User::find($userId);
     //example posted data: adminRole=Add
     Role::all()->each(function ($role) {
         if (Input::has($role->description . "Role")) {
             Input::get($role->description . "Role");
             $action = Input::get($inputName);
             if ($action === "Add") {
                 $user->roles()->attach($role);
             } elseif ($action === "Remove") {
                 $user->roles()->detach($role);
             } else {
                 Redirect::to('/error/whatAreYouEvenTryingToDo');
             }
         }
     });
     return Redirect::to('/user/' . $user->id);
 }
开发者ID:noikiy,项目名称:Laravel-5-Helpdesk,代码行数:26,代码来源:HelpDeskController.php

示例10: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $roles = Role::all();
     $actions = ActionSchema::getActionSchema($this->module);
     //return  Feature::test();
     return view('backend.role.index')->with('content_title', "Manage Roles")->with('actions', $actions)->with('roles', $roles)->with('module', $this->module);
 }
开发者ID:vampirethura,项目名称:modelvillage,代码行数:12,代码来源:RoleController.php

示例11: users

 public function users()
 {
     $users = User::with('organization', 'roles')->get(['id', 'name', 'email', 'organization_id']);
     $orgs = Organization::all();
     $roles = Role::all();
     return Datatables::of($users)->addColumn('organization', function ($user) use($orgs) {
         $orgSelect = '<select name="organization" class="form-control organization" data-userid="' . $user->id . '">';
         foreach ($orgs as $org) {
             $select = "";
             if ($org->id == $user->organization_id) {
                 $select = 'selected';
             }
             $orgSelect .= '<option value="' . $org->id . '" ' . $select . '>' . $org->name . '</option>';
         }
         $orgSelect .= '</select>';
         //return '<a href="#edit-'.$user->id.'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> '.$user->organization->name.'</a>';
         return $orgSelect;
     })->addColumn('role', function ($user) use($roles) {
         $roleSelect = '<select name="organization" class="form-control role" data-userid="' . $user->id . '">';
         foreach ($roles as $role) {
             $select = "";
             if ($user->hasRole($role->name)) {
                 $select = 'selected';
             }
             $roleSelect .= '<option value="' . $role->id . '" ' . $select . '>' . $role->display_name . '</option>';
         }
         $roleSelect .= '</select>';
         //return '<a href="#edit-'.$user->id.'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> '.$user->roles[0]->display_name.'</a>';
         return $roleSelect;
     })->removeColumn('id')->removeColumn('organization_id')->make(true);
 }
开发者ID:gfdeveloper,项目名称:LCCB,代码行数:31,代码来源:ApiController.php

示例12: index

 /**
  * Displays the users dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $roles = Role::all();
     $institutionsTeach = Auth::user()->institutions(1)->get();
     $institutionsMod = Auth::user()->institutions(2)->get();
     return view('user.dashboard')->with('roles', $roles)->with('institutionsTeach', $institutionsTeach)->with('institutionsMod', $institutionsMod);
 }
开发者ID:salvomulas,项目名称:angryproton,代码行数:12,代码来源:UserController.php

示例13: roleExist

 public static function roleExist($role)
 {
     $allRoles = Role::all();
     if (is_string($role)) {
         return $allRoles->contains('name', $role);
     }
 }
开发者ID:abreban,项目名称:RGU,代码行数:7,代码来源:Role.php

示例14: test

 public function test(Request $request)
 {
     //            $user = User::find(1);
     //
     //            if($user->hasRole('Founder')){
     //                return '您是创始人'.'ID:'.$user->id;
     //            };
     if ($request->user()) {
         //                $userRoles = $request->user()->roles()->get();
         //                foreach($userRoles as $r){
         //                    $roles[] = $r->name;
         //                }
         //                var_dump($roles);
         $userRoles = Role::all();
         foreach ($userRoles as $r) {
             $roles[] = $r->name;
         }
         if (!$request->user()->hasRole($roles)) {
             return redirect()->guest('auth/login');
         }
         //$can = Route::currentRouteName();//当前route-name  exp:user.test
         $can = Route::currentRouteAction();
         echo $can;
         $res = $request->user()->can($can);
         echo $res;
     }
 }
开发者ID:nutsdo,项目名称:rp-wechat,代码行数:27,代码来源:UserController.php

示例15: edit

 public function edit($id)
 {
     $user = User::whereId($id)->firstOrFail();
     $roles = Role::all();
     $selectedRoles = $user->roles->lists('id')->toArray();
     return view('backend.users.edit', compact('user', 'roles', 'selectedRoles'));
 }
开发者ID:steve8809,项目名称:pentathlon_2015,代码行数:7,代码来源:UsersController.php


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