本文整理汇总了PHP中app\models\Role::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::all方法的具体用法?PHP Role::all怎么用?PHP Role::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Role
的用法示例。
在下文中一共展示了Role::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: roles
public function roles($id)
{
$this->authorize('user_view_roles');
$user = User::find($id);
$roles = Role::all();
return view('admin.users.roles', compact('user', 'roles'));
}
示例2: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit(User $User)
{
$this->data['Roles'] = Role::all();
$this->data['Groups'] = Group::all();
$this->data['User'] = $User;
return view('admin.users.edit', $this->data);
}
示例3: form
/**
* Returns a new form for the specified user.
*
* @param User $user
*
* @return \Orchestra\Contracts\Html\Builder
*/
public function form(User $user)
{
return $this->form->of('users', function (FormGrid $form) use($user) {
if ($user->exists) {
$method = 'PATCH';
$url = route('admin.users.update', [$user->getKey()]);
$form->submit = 'Save';
} else {
$method = 'POST';
$url = route('admin.users.store');
$form->submit = 'Create';
}
$form->attributes(compact('method', 'url'));
$form->with($user);
$form->fieldset(function (Fieldset $fieldset) use($user) {
$fieldset->control('input:text', 'name')->attributes(['placeholder' => 'Enter the users name.']);
$fieldset->control('input:text', 'email')->attributes(['placeholder' => 'Enter the users email address.']);
if ($user->exists) {
$fieldset->control('input:select', 'roles[]')->label('Roles')->options(function () {
return Role::all()->pluck('label', 'id');
})->value(function (User $user) {
return $user->roles->pluck('id');
})->attributes(['class' => 'select-roles', 'multiple' => true]);
}
$fieldset->control('input:password', 'password')->attributes(['placeholder' => 'Enter a password to change the users password.']);
$fieldset->control('input:password', 'password_confirmation')->attributes(['placeholder' => 'Enter the users password again.']);
});
});
}
示例4: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
*
* @return mixed
*/
public function edit($id)
{
$availableAppointment = AvailableAppointment::findOrFail($id);
$fixtures = Fixture::all();
$roles = Role::all();
return view('admin.data-management.available-appointments.edit', compact('availableAppointment', 'fixtures', 'roles'));
}
示例5: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$user = User::find($id);
$role = Role::find($user->type);
$roles = Role::all();
return view('user.edit', compact('user', 'role', 'roles'));
}
示例6: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$roles = Role::all();
$permissions = Permission::all();
$usersWithRoles = User::with('roles')->orderBy('last_name')->get();
return view('admin.roles.index', ['roles' => $roles, 'permissions' => $permissions, 'users' => $usersWithRoles]);
}
示例7: getAllRoles
public function getAllRoles($relationships = null)
{
if (isset($relationships)) {
return Role::with($relationships)->get();
}
return Role::all();
}
示例8: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$permissions = $this->getAllActions();
$actions = $this->getRouteData();
$roles = Role::all();
// Add new actions
foreach ($actions as $action => $uri) {
if (!array_key_exists($action, $permissions)) {
$newAction = new Action(['action' => $action, 'uri' => $uri]);
$newAction->save();
$this->savePermissions($roles, $newAction);
$this->info("Added " . $action . "\n");
} else {
unset($permissions[$action]);
}
}
// Remove non existing actions
foreach ($permissions as $action => $uri) {
Action::where(['action' => $action, 'uri' => $uri])->first()->destroy();
$this->comment("Removed " . $action . "\n");
}
$cache = $this->getCacheInstance(['permissions']);
$cache->flush();
$this->info("Done. \n");
}
示例9: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->info("Clearing permissions... \n");
// Delete old data
$response = Action::deleteAllData();
null !== $response ? $this->error("\n" . $response . "\n") : null;
$this->info("Permissions cleared... \n");
try {
$routeData = $this->getRouteData();
$roles = Role::all();
DB::beginTransaction();
foreach ($routeData as $action => $uri) {
$action = new Action(['uri' => $uri, 'action' => $action]);
$action->save();
$this->savePermissions($roles, $action);
$this->comment("Added action " . $action->action . "\n");
}
$cache = $this->getCacheInstance(['permissions']);
$cache->flush();
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
$this->error("\n" . $e->getMessage() . "\n");
}
}
示例10: edit
/**
* Add user page
*
* @return response
*/
public function edit($id)
{
$roles = ['' => _t('backend_user_select_role')];
foreach (Role::all() as $role) {
$roles[$role->id] = $role->name;
}
return view('backend::user.form', ['user' => $this->_getUserById($id), 'roles' => $roles]);
}
示例11: getEdit
public function getEdit($id)
{
$roles = [];
foreach (Role::all() as $role) {
$roles[$role->id] = $role->title;
}
return view('admin.users.details', ['user' => User::find($id), 'roles' => $roles]);
}
示例12: allConPermisos
public static function allConPermisos($detailed = false)
{
$roles = Role::all();
foreach ($roles as $rol) {
$rol->perms = $rol->permissions($detailed);
}
return $roles;
}
示例13: getRolesDropdownOptions
/**
* Get dropdown of all roles available for user
*
* @return mixed
*/
public function getRolesDropdownOptions()
{
$allRoles = Role::all();
foreach ($allRoles as $eachRole) {
$results[$eachRole->id] = $eachRole->custom_role_name;
}
return $results;
}
示例14: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
// $auths = Models\Role::find(12)->auths;
// foreach($auths as $auth){
// echo $auth->auth_name;
// }
return view('admin.role.index')->withRoles(Models\Role::all());
}
示例15: getRegister
/**
* Show the application registration form.
*
* @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed
*/
public function getRegister()
{
// Prepare dropdown for roles
$allRoles = Role::all();
foreach ($allRoles as $eachRole) {
$rolesOptions[$eachRole->id] = $eachRole->custom_role_name;
}
$viewHtml = view('pages.main.user', ['mode' => 'register', 'user' => '', 'rolesOptions' => $rolesOptions, 'rolesSelectedOptions' => ''])->render();
return response()->json(["viewBody" => $viewHtml]);
}