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


PHP Role::get方法代码示例

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


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

示例1: show

 /**
  * Display linked records of the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     // get all -- USERS -- with this specific role id
     $role = Role::find($id);
     $heading = 'User Management - Show ' . ucfirst($role->name) . 's';
     return view('admin.users', ['users' => $role->users()->get(), 'heading' => $heading, 'roles' => Role::get(), 'instruments' => Instrument::get()]);
 }
开发者ID:matthiku,项目名称:cSpot,代码行数:13,代码来源:RoleController.php

示例2: show

 public function show($id)
 {
     if (Auth::user()->can('read-group')) {
         $data['group'] = Group::find($id);
         $data['title'] = "Group \"" . $data['group']->display_name . "\"";
         $roles = Role::get();
         $roles_in_group = Role::whereHas('groups', function ($q) use($id) {
             $q->where('groups.id', $id);
         })->get();
         $counter = 0;
         foreach ($roles as $role) {
             $is_in_group = false;
             foreach ($roles_in_group as $role_in_group) {
                 if ($role->id == $role_in_group->id) {
                     $is_in_group = true;
                 }
             }
             $data['roles'][$counter] = $role;
             $data['roles'][$counter]['is_in_group'] = $is_in_group;
             $counter++;
         }
         $data['menu_actions'] = [Form::editItem(route('groups.edit', $id), 'Edit This Group', Auth::user()->can('update-group'))];
         return view('groups/show', $data);
     } else {
         return redirect()->back()->withErrors(['Access denied to groups show page']);
     }
 }
开发者ID:pinkynrg,项目名称:convergence2.0,代码行数:27,代码来源:GroupsController.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     if (Role::get()->count() == 0) {
         Role::create(['name' => 'admin', 'display_name' => 'Admin', 'description' => 'User can adminstrate the site']);
         Role::create(['name' => 'user', 'display_name' => 'User', 'description' => 'User can navigate the site']);
     }
     if (User::get()->count() == 0) {
         User::create(['name' => env('ROOT_USER_NAME', 'Test User'), 'email' => env('ROOT_USER_EMAIL', 'testuser@test.com'), 'password' => Hash::make(env('ROOT_USER_PASSWORD', 'password'))])->attachRole(Role::where('name', '=', 'admin')->first());
     }
 }
开发者ID:nich-mctishe,项目名称:laravel-framework,代码行数:15,代码来源:UsersTableSeeder.php

示例4: show

 /**
  * Display linked records of the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     // get all -- USERS -- with this specific instrument id
     $instrument = Instrument::find($id);
     if ($instrument) {
         $heading = 'User Management - Users playing ' . ucfirst($instrument->name);
         return view('admin.users', ['users' => $instrument->users()->get(), 'heading' => $heading, 'roles' => Role::get(), 'instruments' => Instrument::get()]);
     }
     $message = 'Error! Instrument with ID "' . $id . '" not found';
     return \Redirect::route($this->view_idx)->with(['status' => $message]);
 }
开发者ID:matthiku,项目名称:cSpot,代码行数:17,代码来源:InstrumentController.php

示例5: edit

 public function edit()
 {
     $user = User::find(Input::get('id'));
     $action = "admin.systemusers.save";
     $roles = Role::get(['id', 'display_name'])->toArray();
     $roles_name = ["" => "Please Select"];
     foreach ($roles as $role) {
         $roles_name[$role['id']] = $role['display_name'];
     }
     return view(Config('constants.adminSystemUsersView') . '.addEdit', compact('user', 'action', 'roles_name'));
 }
开发者ID:sushilcs111,项目名称:sourcesunlimited,代码行数:11,代码来源:SystemUsersController.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Role::create(['name' => 'Admin', 'display_name' => '超级管理员']);
     Role::create(['name' => 'Editor', 'display_name' => '编辑']);
     Role::create(['name' => 'Demo', 'display_name' => '演示']);
     Role::get()->each(function ($role) {
         if ($role->name === 'Admin') {
             $permissions = Permission::get()->pluck('id')->all();
             $role->perms()->sync($permissions);
         }
         if ($role->name === 'Editor') {
             $permissions = Permission::where('name', 'manage_contents')->first();
             $role->perms()->sync([$permissions->id]);
         }
     });
 }
开发者ID:axex,项目名称:kratos,代码行数:21,代码来源:RoleTableSeeder.php

示例7: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     // show only active users
     // TODO: this currently produces duplicates...
     if ($request->has('active')) {
         $user1 = Role::find(4)->users()->get();
         $users = Role::find(5)->users()->get();
         foreach ($user1 as $value) {
             $users->prepend($value);
         }
         $heading = 'Show Active Users';
         return view($this->view_all, ['users' => $users, 'heading' => $heading, 'roles' => Role::get(), 'instruments' => Instrument::get()]);
     }
     // get all users in the requested order (default by id)
     $users = User::orderBy(isset($request->orderby) ? $request->orderby : 'id', isset($request->order) ? $request->order : 'asc');
     $heading = 'User Management';
     // check if user selected a filter
     if ($request->has('filterby') && $request->has('filtervalue') && $request->filtervalue != 'all') {
         if ($request->filterby == 'role') {
             // get all -- USERS -- with this specific role id
             $role = Role::find($request->filtervalue);
             $users = $role->users();
             $heading = 'User Management - Show ' . ucfirst($role->name) . 's';
         } else {
             if ($request->filterby == 'instrument') {
                 // get all -- USERS -- with this specific instrument id
                 $instrument = Instrument::find($request->filtervalue);
                 $users = $instrument->users();
                 $heading = 'User Management - Show users playing ' . ucfirst($instrument->name);
             } else {
                 $users = $users->where($request->filterby, $request->filtervalue);
             }
         }
     }
     return view($this->view_all, ['users' => $users->get(), 'heading' => $heading, 'roles' => Role::get(), 'instruments' => Instrument::get()]);
 }
开发者ID:matthiku,项目名称:cSpot,代码行数:41,代码来源:UserController.php

示例8: EditView

 public function EditView($id)
 {
     if (!is_null($id)) {
         if (Auth::check()) {
             if (in_array('ADD_EDIT_USER', $this->permission)) {
                 $user_obj = User::with('getCompany')->find($id);
                 if (User::isSuperAdmin()) {
                     $company_obj = Company::all();
                     $role_obj = Role::get();
                 } else {
                     $company_obj = User::with('getCompany')->find(Auth::user()->id);
                     $role_obj = Role::where('id', '>', 1)->get();
                 }
                 return view('user.edit')->with('user_obj', $user_obj)->with('company_obj', $company_obj)->with('role_obj', $role_obj);
             }
             return \Redirect::back()->withErrors(['success' => false, 'msg' => 'You don\'t have permission']);
         }
         return Redirect::to(url('user/login'));
     }
     return \Redirect::back()->withErrors(['success' => false, 'msg' => 'somethings went wrongs']);
 }
开发者ID:bluelinemango,项目名称:mango,代码行数:21,代码来源:UsersController.php

示例9: assign_per_role

 public function assign_per_role()
 {
     $roles = Role::get(['id', 'name']);
     $permissions = Permission::get(['id', 'name']);
     return view('assign_per_role', compact('roles', 'permissions'));
 }
开发者ID:sushilcs111,项目名称:sourcesunlimited,代码行数:6,代码来源:PermissionsController.php

示例10: index

 /**
  * Muestra el listado de roles.
  *
  * @return Response
  */
 public function index()
 {
     $role = Role::get();
     return response()->json(["msg" => "Success", "items" => $role], 200);
 }
开发者ID:whoOami,项目名称:potential-smd,代码行数:10,代码来源:RoleController.php


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