本文整理汇总了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'));
}
示例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;
}
示例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');
}
示例4: getRoles
public function getRoles()
{
if (empty($this->roles)) {
$this->roles = Role::all();
}
return $this->roles;
}
示例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')));
}
示例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]);
}
示例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.');
}
}
}
示例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));
}
示例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');
}
}
示例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'));
}
}
示例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'));
}
}
示例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'));
}
}
示例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'));
}
示例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'));
}
}
示例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);
}