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