本文整理汇总了PHP中app\models\Permission::lists方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::lists方法的具体用法?PHP Permission::lists怎么用?PHP Permission::lists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Permission
的用法示例。
在下文中一共展示了Permission::lists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$role = \App\Models\Role::findOrFail($id);
$this->authorize('update', $role);
$list = \App\Models\Permission::lists('title', 'id');
// dd($role->permissions()->lists('id'));
return view('roles.edit', ['pList' => $list, 'role' => $role]);
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$pIds = Permission::lists('id');
//superadmin
foreach ($pIds as $id) {
DB::table('permission_role')->insert(['permission_id' => $id, 'role_id' => 1]);
}
//admin
DB::table('permission_role')->insert([['permission_id' => 1, 'role_id' => 2], ['permission_id' => 2, 'role_id' => 2], ['permission_id' => 3, 'role_id' => 2], ['permission_id' => 4, 'role_id' => 2], ['permission_id' => 6, 'role_id' => 2], ['permission_id' => 11, 'role_id' => 2], ['permission_id' => 13, 'role_id' => 2], ['permission_id' => 16, 'role_id' => 2], ['permission_id' => 17, 'role_id' => 2], ['permission_id' => 18, 'role_id' => 2], ['permission_id' => 19, 'role_id' => 2], ['permission_id' => 21, 'role_id' => 2], ['permission_id' => 22, 'role_id' => 2], ['permission_id' => 23, 'role_id' => 2], ['permission_id' => 24, 'role_id' => 2], ['permission_id' => 26, 'role_id' => 2], ['permission_id' => 27, 'role_id' => 2], ['permission_id' => 28, 'role_id' => 2], ['permission_id' => 29, 'role_id' => 2], ['permission_id' => 30, 'role_id' => 2]]);
//editor
DB::table('permission_role')->insert([['permission_id' => 1, 'role_id' => 3], ['permission_id' => 3, 'role_id' => 3], ['permission_id' => 21, 'role_id' => 3], ['permission_id' => 23, 'role_id' => 3], ['permission_id' => 27, 'role_id' => 3], ['permission_id' => 29, 'role_id' => 3]]);
}
示例3: run
public function run()
{
// Attach permission to role
//DB::table(Config::get('entrust.permission_role_table'))->forceDelete();
DB::table(Config::get('entrust.permission_role_table'))->truncate();
$role = Role::find(1);
$role->perms()->attach(Permission::lists('id')->all());
$role = Role::find(2);
$role->perms()->attach(Permission::lists('id')->all());
// Attach role to user
//DB::table(Config::get('entrust.role_user_table'))->forceDelete();
DB::table(Config::get('entrust.role_user_table'))->truncate();
$user = User::find(1);
$user->roles()->attach(Role::find(1));
}
示例4: addPermission
/**
* Add permissions to user to make them a concierge
*/
public function addPermission($title)
{
$assigned_permissions = array();
$permissions = Permission::lists('permission');
switch ($title) {
case 'admin':
$assigned_permissions[] = $this->getIdInArray($permissions, 'view_lecturer');
$assigned_permissions[] = $this->getIdInArray($permissions, 'create_lecturer');
$assigned_permissions[] = $this->getIdInArray($permissions, 'edit_lecturer');
$assigned_permissions[] = $this->getIdInArray($permissions, 'delete_lecturer');
$assigned_permissions[] = $this->getIdInArray($permissions, 'view_user');
$assigned_permissions[] = $this->getIdInArray($permissions, 'create_user');
$assigned_permissions[] = $this->getIdInArray($permissions, 'edit_user');
$assigned_permissions[] = $this->getIdInArray($permissions, 'delete_user');
$assigned_permissions[] = $this->getIdInArray($permissions, 'view_student');
$assigned_permissions[] = $this->getIdInArray($permissions, 'create_student');
$assigned_permissions[] = $this->getIdInArray($permissions, 'edit_student');
$assigned_permissions[] = $this->getIdInArray($permissions, 'delete_student');
$assigned_permissions[] = $this->getIdInArray($permissions, 'view_university');
$assigned_permissions[] = $this->getIdInArray($permissions, 'create_university');
$assigned_permissions[] = $this->getIdInArray($permissions, 'edit_university');
$assigned_permissions[] = $this->getIdInArray($permissions, 'delete_university');
$assigned_permissions[] = $this->getIdInArray($permissions, 'view_sos_request');
$assigned_permissions[] = $this->getIdInArray($permissions, 'create_sos_request');
$assigned_permissions[] = $this->getIdInArray($permissions, 'edit_sos_request');
$assigned_permissions[] = $this->getIdInArray($permissions, 'delete_sos_request');
case 'lecturer':
$assigned_permissions[] = $this->getIdInArray($permissions, 'view_student');
$assigned_permissions[] = $this->getIdInArray($permissions, 'view_profile');
$assigned_permissions[] = $this->getIdInArray($permissions, 'edit_profile');
$assigned_permissions[] = $this->getIdInArray($permissions, 'view_sos_request');
$assigned_permissions[] = $this->getIdInArray($permissions, 'create_sos_request');
$assigned_permissions[] = $this->getIdInArray($permissions, 'delete_sos_request');
case 'student':
$assigned_permissions[] = $this->getIdInArray($permissions, 'view_profile');
$assigned_permissions[] = $this->getIdInArray($permissions, 'edit_profile');
$assigned_permissions[] = $this->getIdInArray($permissions, 'view_sos_request');
$assigned_permissions[] = $this->getIdInArray($permissions, 'create_sos_request');
$assigned_permissions[] = $this->getIdInArray($permissions, 'delete_sos_request');
break;
default:
throw new \Exception("The employee status entered does not exist");
}
$this->permissions()->attach($assigned_permissions);
}
示例5: composerRoleForm
private function composerRoleForm()
{
view()->composer('admin.roles.fields', function ($view) {
$view->with('permissions', \App\Models\Permission::lists('name', 'id'));
});
}