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


PHP Role::all方法代码示例

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


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

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $roles = $this->role->all();
     if (Request::ajax()) {
         $roles = Role::where('role', 'like', '%' . Input::get('term', '') . '%')->get(array('id', 'role'));
         return $roles;
     }
     return View::make('roles.index', compact('roles'));
 }
开发者ID:Atiragram,项目名称:poit-labs,代码行数:14,代码来源:RolesController.php

示例2: group

 /**
  * Get list Permission filter by group
  * @return mixed
  */
 public function group()
 {
     $perms = $this->model->all(['name', 'id', 'display_name']);
     $group = [];
     foreach ($perms as $perm) {
         $p = explode('.', $perm->name);
         $group[$p[0]][$perm->id] = $perm->display_name;
     }
     return $group;
 }
开发者ID:vnzacky,项目名称:dog,代码行数:14,代码来源:EloquentPermissionRepository.php

示例3: it_can_attach_and_detach_roles

 /** @test */
 public function it_can_attach_and_detach_roles()
 {
     // add a single role to a user
     $user = User::find(3);
     $this->assertFalse($user->hasRole('Admin'), 'Does not have admin role yet');
     $this->assertFalse($user->hasRole('Editor'), 'Does not have editor role yet');
     $this->assertFalse($user->hasRole('Blogger'), 'Does not have blogger role yet');
     $user->attachRoles(Role::all());
     $user = User::find(3);
     $this->assertTrue($user->hasRole('Admin'), 'Has admin role now');
     $this->assertTrue($user->hasRole('Editor'), 'Has editor role now');
     $this->assertTrue($user->hasRole('Blogger'), 'Has blogger role now');
     $user->detachRoles(1);
     $user = User::find(3);
     $this->assertFalse($user->hasRole('Admin'), 'no admin role now');
     $this->assertTrue($user->hasRole('Editor'), 'Has editor role now');
     $this->assertTrue($user->hasRole('Blogger'), 'Has blogger role now');
     $user->detachRoles([2, 3]);
     $user = User::find(3);
     $this->assertFalse($user->hasRole('Admin'), 'Does not have admin role yet');
     $this->assertFalse($user->hasRole('Editor'), 'Does not have editor role yet');
     $this->assertFalse($user->hasRole('Blogger'), 'Does not have blogger role yet');
     $user->attachRoles(Role::find(2));
     $user = User::find(3);
     $this->assertFalse($user->hasRole('Admin'), 'Does not have admin role yet');
     $this->assertTrue($user->hasRole('Editor'), 'Does have editor role yet');
     $this->assertFalse($user->hasRole('Blogger'), 'Does not have blogger role yet');
 }
开发者ID:alexhouse,项目名称:trust,代码行数:29,代码来源:UserRoleTest.php

示例4: getRoles

 public function getRoles()
 {
     if (empty($this->roles)) {
         $this->roles = Role::all();
     }
     return $this->roles;
 }
开发者ID:mermetbt,项目名称:biome,代码行数:7,代码来源:RolesCollection.php

示例5: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $user = User::find($id);
     $userRole = $user->roles()->first();
     $user['rol'] = $userRole;
     return View::make('users.edit', array('user' => $user, 'roles' => Role::all()->lists('name', 'id')));
 }
开发者ID:ofcadavidm,项目名称:laravel-entrust,代码行数:13,代码来源:UserController.php

示例6: edit

 public function edit($id)
 {
     $user = User::with('AssigmentRole')->with('Neighbors')->findOrFail($id);
     $status = Status::all();
     $roles = Role::all();
     return View::make('dashboard.users.edit', ['row' => $user, 'status' => $status, 'roles' => $roles]);
 }
开发者ID:prianticonsulting,项目名称:Habitaria,代码行数:7,代码来源:UsersController.php

示例7: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     if ($this->argument('name')) {
         $name = trim($this->argument('name'));
         $role = Role::where('name', '=', $name)->first();
         if ($role) {
             $this->info("Role '{$name}' already exists.");
             exit;
         }
         $role = new Role();
         $role->name = $name;
         $role->save();
         $this->info('Role saved successfully.');
     } else {
         $roles = Role::all();
         $this->info('Existing Roles:');
         foreach ($roles as $role) {
             $this->info($role->name);
         }
         $continue = $this->ask("Would you still like to add a new role? (yes/no)");
         if ('yes' === trim(strtolower($continue))) {
             $name = $this->ask("What's the new role's name?");
             $role = new Role();
             $role->name = trim($name);
             $role->save();
             $this->info('Role saved successfully.');
         }
     }
 }
开发者ID:krues8dr,项目名称:madison,代码行数:34,代码来源:CreateRole.php

示例8: create

 public static function create()
 {
     $roles = Role::all();
     if (count($roles) <= 0) {
         flash()->error(':(', 'Rooleja ei löytynyt');
         Redirect::to('/roles/create');
     }
     View::make('importances-create.html', array('roles' => $roles));
 }
开发者ID:KristianLauttamus,项目名称:HospitalSchedule,代码行数:9,代码来源:ImportancesController.php

示例9: index

 public function index()
 {
     $active = 'user';
     if (Auth::user()) {
         $user = User::with('role')->where('user_id', Auth::user()->user_id)->first();
         $users = User::nonAdministrator()->get();
         $roles = Role::all();
         return View::make('user', compact('user', 'active', 'users', 'roles'));
     } else {
         return View::make('login');
     }
 }
开发者ID:Ganamuhibudin,项目名称:nomorsurat,代码行数:12,代码来源:UserController.php

示例10: delete

 /**
  * Remove user.
  *
  * @param $user
  * @return Response
  */
 public function delete($user)
 {
     if ($user->id) {
         $roles = $this->role->all();
         $permissions = $this->permission->all();
         // Title
         $title = Lang::get('admin/user/title.user_delete');
         return View::make('admin/user/delete', compact('user', 'roles', 'permissions', 'title'));
     } else {
         return Redirect::to('admin/user')->with('error', Lang::get('admin/user/messages.does_not_exist'));
     }
 }
开发者ID:ferns24,项目名称:catastro,代码行数:18,代码来源:AdminUserController.php

示例11: getEdit

 public function getEdit($user)
 {
     if ($user->id) {
         $roles = $this->role->all();
         $profiles = $user->profiles;
         $permissions = $this->permission->all();
         $title = Lang::get('admin/users/title.user_update');
         $mode = 'edit';
         return View::make('admin/users/create_edit', compact('user', 'roles', 'permissions', 'title', 'mode', 'profiles'));
     } else {
         return Redirect::to('admin/users')->with('error', Lang::get('admin/users/messages.does_not_exist'));
     }
 }
开发者ID:hilmysyarif,项目名称:l4-bootstrap-admin,代码行数:13,代码来源:AdminUsersController.php

示例12: getEdit

 /**
  * edit user
  *
  * @return Response
  */
 public function getEdit($user)
 {
     if ($user->id) {
         $roles = $this->role->all();
         $profiles = $user->profiles;
         $permissions = $this->permission->all();
         $title = Lang::get('admin/users/title.user_update');
         $mode = 'edit';
         $last_login = Activity::whereRaw('user_id = ? AND content_type="login"', array($user->id))->select(array('details'))->orderBy('id', 'DESC')->first();
         return Theme::make('admin/users/create_edit', compact('user', 'roles', 'permissions', 'title', 'mode', 'profiles', 'last_login'));
     } else {
         return Api::to(array('error', Lang::get('admin/users/messages.does_not_exist'))) ?: Redirect::to('admin/users')->with('error', Lang::get('admin/users/messages.does_not_exist'));
     }
 }
开发者ID:Aranjedeath,项目名称:l4-starter,代码行数:19,代码来源:AdminUsersController.php

示例13: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param $role
  * @return Response
  */
 public function edit($id)
 {
     $role = Role::find($id);
     $roles = $this->role->all();
     $permissions = Permission::all();
     // Title
     $title = Lang::get('admin/role/title.role_update');
     //Título de sección:
     $title_section = "Modificar rol: ";
     //Subtítulo de sección:
     $subtitle_section = $role->name;
     // Show the page
     return View::make('admin/role/edit', compact('role', 'roles', 'permissions', 'title', 'title_section', 'subtitle_section'));
 }
开发者ID:ferns24,项目名称:catastro,代码行数:20,代码来源:AdminRolesController.php

示例14: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param $id
  * @throws \Acme\Core\Exceptions\EntityNotFoundException
  * @return Response
  */
 public function edit($id)
 {
     $user = $this->userRepository->findById($id);
     if ($user) {
         $roles = $this->role->all();
         $permissions = $this->permission->all();
         // Title
         $title = Lang::get('admin/users/title.user_update');
         // mode
         $mode = 'edit';
         $this->render('admin.users.edit', compact('user', 'roles', 'permissions', 'title', 'mode'));
     } else {
         return Redirect::to('admin.users')->with('error', Lang::get('admin.users.messages.does_not_exist'));
     }
 }
开发者ID:christiannwamba,项目名称:laravel-site,代码行数:22,代码来源:AdminUsersController.php

示例15: editRole

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function editRole($id)
 {
     $data['user'] = Auth::user();
     //Interface
     $data['noAriane'] = true;
     $data['buttonLabel'] = Lang::get('button.update');
     $data['glyphicon'] = 'ok';
     $data['u'] = AuthUser::find($id);
     //Role
     $data['roles'] = Role::all();
     if (empty($data['u'])) {
         return Redirect::back()->with('error', Lang::get('admin.auth_empty'));
     }
     return View::make('theme::' . 'admin.auth.edit_role', $data);
 }
开发者ID:Metrakit,项目名称:dynamix,代码行数:21,代码来源:AdminAuthController.php


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