當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。