本文整理汇总了PHP中app\models\Permission::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::create方法的具体用法?PHP Permission::create怎么用?PHP Permission::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Permission
的用法示例。
在下文中一共展示了Permission::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
DB::table('permission_role')->truncate();
DB::table('role_user')->truncate();
DB::table('users')->truncate();
DB::table('roles')->truncate();
DB::table('permissions')->truncate();
DB::table('permission_groups')->truncate();
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
$faker = Faker\Factory::create();
//User
$admin = User::create(['email' => 'admin@admin.com', 'name' => '管理员', 'password' => bcrypt('adminadmin')]);
$test_user = User::create(['email' => 'test@test.com', 'name' => '测试用户', 'password' => bcrypt('testtest')]);
//Roles
$role_admin = Role::create(['name' => 'admin', 'display_name' => '管理员']);
$role_editor = Role::create(['name' => 'editor', 'display_name' => '编辑']);
$role_user = Role::create(['name' => 'user', 'display_name' => '普通用户']);
//Permission&PermissionGroup
PermissionGroup::create(['name' => '后台']);
PermissionGroup::create(['name' => 'RBAC', 'parent_id' => 1]);
Permission::create(['name' => 'dashboard_view', 'display_name' => '首页', 'group_id' => 1]);
$models = [['route_name' => 'users', 'menu_name' => '帐户', 'group_id' => 3, 'group_pid' => 2], ['route_name' => 'roles', 'menu_name' => '角色', 'group_id' => 4, 'group_pid' => 2], ['route_name' => 'permissions', 'menu_name' => '权限', 'group_id' => 5, 'group_pid' => 2], ['route_name' => 'permissiongroups', 'menu_name' => '权限分组', 'group_id' => 6, 'group_pid' => 2], ['route_name' => 'articles', 'menu_name' => '文章', 'group_id' => 7, 'group_pid' => 1], ['route_name' => 'settings', 'menu_name' => '配置', 'group_id' => 8, 'group_pid' => 1]];
foreach ($models as $key => $model) {
PermissionGroup::create(['name' => $model['menu_name'], 'parent_id' => $model['group_pid']]);
Permission::create(['group_id' => $model['group_id'], 'name' => $model['route_name'] . '_view', 'display_name' => $model['menu_name'] . '菜单']);
Permission::create(['group_id' => $model['group_id'], 'name' => $model['route_name'] . '_create', 'display_name' => '新建' . $model['menu_name']]);
Permission::create(['group_id' => $model['group_id'], 'name' => $model['route_name'] . '_update', 'display_name' => '修改' . $model['menu_name']]);
Permission::create(['group_id' => $model['group_id'], 'name' => $model['route_name'] . '_delete', 'display_name' => '删除' . $model['menu_name']]);
}
//Roles Users
$test_user->roles()->save($role_editor);
//Roles Users
// $role_admin->givePermissionTo($permission_admin_user);
}
示例2: store
/**
* Store a newly created Permissions in storage.
*
* @param CreatePermissionsRequest $request
*
* @return Response
*/
public function store(CreatePermissionsRequest $request)
{
$input = $request->all();
$permissions = Permission::create($input);
Flash::message('Permissions saved successfully.');
return redirect(route('admin.permissions.index'));
}
示例3: create
protected function create($values)
{
$data = [];
foreach ($this->structure as $i => $key) {
$data[$key] = $values[$i];
}
Permission::create($data);
}
示例4: store
/**
* Store a new permission from form request
*
* @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function store(Request $request)
{
$this->authorize('edit_users');
$this->validate($request, ['name' => 'required|string|between:3,50', 'description' => 'string|between:0,100']);
$permission = Permission::create($request->all());
$permission->groups()->attach($request->input('group_list'));
flash()->success('Permission Saved', 'The permission has been created');
return redirect('permission');
}
示例5: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('permissions')->delete();
$permissionArr = array(array('name' => 'add_user', 'display_name' => '添加用户'), array('name' => 'delete_user', 'display_name' => '删除用户'), array('name' => 'add_news', 'display_name' => '添加新闻'), array('name' => 'edit_news', 'display_name' => '编辑新闻'));
foreach ($permissionArr as $perm) {
$permission = \App\Models\Permission::create(['name' => $perm['name'], 'display_name' => $perm['display_name'], 'description' => '']);
DB::insert('insert into permission_role (permission_id, role_id) values (?, ?)', [$permission->id, 1]);
}
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(PermissionRequest $request)
{
$input = $request->all();
$inputn['name'] = ucfirst($request->get('name'));
$inputn[$this->permissions] = Permission::getper($input);
Permission::create($inputn);
Session::flash($this->success, Lang::get('ruban.permission.created'));
return Redirect::route('ruban.permissions.index');
}
示例7: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
$data = $request->all();
$validator = Validator::make($data, ['name' => 'required|max:255|unique:permissions', 'display_name' => 'required|max:255']);
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
Permission::create(['name' => $data['name'], 'cat_id' => $data['cat_id'], 'display_name' => $data['display_name'], 'description' => $data['description']]);
$msg = array('msg' => '已成功添加');
return json_encode($msg);
}
示例8: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// Create a few test users.
$lastNames = [1 => 'One', 2 => 'Two', 3 => 'Three', 4 => 'Four', 5 => 'Five'];
foreach ($lastNames as $index => $lastName) {
$testUser = User::create(['username' => 'user' . $index, 'first_name' => 'User', 'last_name' => $lastName, 'email' => 'user' . $index . '@email.com', "password" => "Password1", "gender" => true, "auth_type" => "internal", "enabled" => true, 'department_id' => 2, "regency_id" => 2]);
}
/////////
// Create a few test permissions for the flash-test pages.
$testLevels = ['success', 'info', 'warning', 'error'];
foreach ($testLevels as $level) {
$permGuestOnly = Permission::create(['name' => 'test-level-' . $level, 'display_name' => 'Test level ' . $level, 'description' => 'Testing level ' . $level, 'enabled' => true]);
}
}
示例9: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker\Factory::create();
$adminUser = User::create(['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'email' => 'admin@yoursite.com', 'password' => bcrypt('password')]);
$adminRole = Role::create(['name' => 'admin', 'display_name' => 'Administrator', 'description' => 'Super administrator role.']);
$permission['manageUsersPerm'] = Permission::create(['name' => 'manage-users', 'display_name' => 'Manage Users', 'description' => 'Has ability to view, create, edit and delete users as well as assign user roles.']);
$permission['managePermissionsPerm'] = Permission::create(['name' => 'manage-permissions', 'display_name' => 'Manage Permissions', 'description' => 'Has ability to view and edit permissions.']);
$permission['manageRolesPerm'] = Permission::create(['name' => 'manage-roles', 'display_name' => 'Manage Roles', 'description' => 'Has ability to view, create, edit and delete roles as well as assign role permissions.']);
$adminRole->attachPermissions($permission);
$adminUser->attachRole($adminRole);
for ($i = 0; $i < 100; $i++) {
// random users
$user = User::create(['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'email' => $faker->email, 'password' => bcrypt('pass')]);
}
}
示例10: run
public function run()
{
$ownerRole = Role::create(['name' => 'owner', 'display_name' => 'owner']);
$allPermissions = [];
$adminRolePermission = Permission::create(['name' => 'auth.backend', 'display_name' => 'Login to backend']);
array_push($allPermissions, $adminRolePermission->id);
$listRolePermission = Permission::create(['name' => 'roles.index', 'display_name' => 'List Roles']);
$createRolePermission = Permission::create(['name' => 'roles.store', 'display_name' => 'Create Roles']);
$editRolePermission = Permission::create(['name' => 'roles.update', 'display_name' => 'Edit Roles']);
$deleteRolePermission = Permission::create(['name' => 'roles.destroy', 'display_name' => 'Delete Roles']);
array_push($allPermissions, $listRolePermission->id, $createRolePermission->id, $editRolePermission->id, $listRolePermission->id, $deleteRolePermission->id);
$listUserPermission = Permission::create(['name' => 'users.index', 'display_name' => 'List Users']);
$createUserPermission = Permission::create(['name' => 'users.store', 'display_name' => 'Create Users']);
$editUserPermission = Permission::create(['name' => 'users.update', 'display_name' => 'Edit Users']);
$deleteUserPermission = Permission::create(['name' => 'users.destroy', 'display_name' => 'Delete Users']);
array_push($allPermissions, $listUserPermission->id, $createUserPermission->id, $editUserPermission->id, $listUserPermission->id, $deleteUserPermission->id);
$listPostPermission = Permission::create(['name' => 'posts.index', 'display_name' => 'List Posts']);
$createPostPermission = Permission::create(['name' => 'posts.store', 'display_name' => 'Create Posts']);
$editPostPermission = Permission::create(['name' => 'posts.update', 'display_name' => 'Edit Posts']);
$deletePostPermission = Permission::create(['name' => 'posts.destroy', 'display_name' => 'Delete Posts']);
array_push($allPermissions, $listPostPermission->id, $createPostPermission->id, $editPostPermission->id, $listPostPermission->id, $deletePostPermission->id);
$listPostCategoryPermission = Permission::create(['name' => 'posts.categories.index', 'display_name' => 'List Posts Categories']);
$createPostCategoryPermission = Permission::create(['name' => 'posts.categories.store', 'display_name' => 'Create Posts Categories']);
$editPostCategoryPermission = Permission::create(['name' => 'posts.categories.update', 'display_name' => 'Edit Posts Categories']);
$deletePostCategoryPermission = Permission::create(['name' => 'posts.categories.destroy', 'display_name' => 'Delete Posts Categories']);
array_push($allPermissions, $listPostCategoryPermission->id, $createPostCategoryPermission->id, $editPostCategoryPermission->id, $listPostCategoryPermission->id, $deletePostCategoryPermission->id);
$listMediaPermission = Permission::create(['name' => 'media.index', 'display_name' => 'List Media']);
$createMediaPermission = Permission::create(['name' => 'media.store', 'display_name' => 'Create Media']);
$editMediaPermission = Permission::create(['name' => 'media.update', 'display_name' => 'Edit Media']);
$deleteMediaPermission = Permission::create(['name' => 'media.destroy', 'display_name' => 'Delete Media']);
array_push($allPermissions, $listMediaPermission->id, $createMediaPermission->id, $editMediaPermission->id, $listMediaPermission->id, $deleteMediaPermission->id);
$listMediaCategoryPermission = Permission::create(['name' => 'media.categories.index', 'display_name' => 'List Media Categories']);
$createMediaCategoryPermission = Permission::create(['name' => 'media.categories.store', 'display_name' => 'Create Media Categories']);
$editMediaCategoryPermission = Permission::create(['name' => 'media.categories.update', 'display_name' => 'Edit Media Categories']);
$deleteMediaCategoryPermission = Permission::create(['name' => 'media.categories.destroy', 'display_name' => 'Delete Media Categories']);
array_push($allPermissions, $listMediaCategoryPermission->id, $createMediaCategoryPermission->id, $editMediaCategoryPermission->id, $listMediaCategoryPermission->id, $deleteMediaCategoryPermission->id);
$ownerRole->perms()->sync($allPermissions);
$user = User::create(['firstname' => 'Mark', 'email' => 'admin@emcoo.com', 'password' => 'adminmark', 'last_login' => date('Y-m-d H:i:s')]);
$user->attachRole($ownerRole);
}
示例11: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$admin = Role::create(['name' => 'administrator', 'label' => 'Administrator']);
$updateApplication = Permission::create(['name' => 'update.application', 'label' => 'Update the Application']);
$manager = Role::create(['name' => 'manager', 'label' => 'Site Manager']);
$viewAdmin = Permission::create(['name' => 'view.admin', 'label' => 'Visit the Admin Area']);
$manager->givePermissionTo($viewAdmin);
//users
$viewUsers = Permission::create(['name' => 'view.users', 'label' => 'View Users']);
$manager->givePermissionTo($viewUsers);
$createUsers = Permission::create(['name' => 'create.users', 'label' => 'Create Users']);
$manager->givePermissionTo($createUsers);
$updateUsers = Permission::create(['name' => 'update.users', 'label' => 'Update Users']);
$manager->givePermissionTo($updateUsers);
$deleteUsers = Permission::create(['name' => 'delete.users', 'label' => 'Delete Users']);
$manager->givePermissionTo($deleteUsers);
//roles
$viewRoles = Permission::create(['name' => 'view.roles', 'label' => 'View Roles']);
$manager->givePermissionTo($viewRoles);
$createRoles = Permission::create(['name' => 'create.roles', 'label' => 'Create Roles']);
$manager->givePermissionTo($createRoles);
$updateRoles = Permission::create(['name' => 'update.roles', 'label' => 'Update Roles']);
$manager->givePermissionTo($updateRoles);
$deleteRoles = Permission::create(['name' => 'delete.roles', 'label' => 'Delete Roles']);
$manager->givePermissionTo($deleteRoles);
//settings
$viewSettings = Permission::create(['name' => 'view.settings', 'label' => 'View Settings']);
$manager->givePermissionTo($viewSettings);
$updateSettings = Permission::create(['name' => 'update.settings', 'label' => 'Update Settings']);
$manager->givePermissionTo($updateSettings);
$viewPages = Permission::create(['name' => 'view.pages', 'label' => 'View Pages']);
$manager->givePermissionTo($viewPages);
$createPages = Permission::create(['name' => 'create.pages', 'label' => 'Create Pages']);
$manager->givePermissionTo($createPages);
$updatePages = Permission::create(['name' => 'update.pages', 'label' => 'Update Pages']);
$manager->givePermissionTo($updatePages);
$deletePages = Permission::create(['name' => 'delete.pages', 'label' => 'Delete Pages']);
$manager->givePermissionTo($deletePages);
}
示例12: run
public function run()
{
Permission::truncate();
Permission::create(['name' => 'login-web', 'permission' => 'Login to Web', 'description' => 'Allow user to log in via web.', 'is_default' => 1, 'is_readonly' => 1]);
Permission::create(['name' => 'login-api', 'permission' => 'Login via API', 'description' => 'Allow user to log in via API.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'edit-profile-web', 'permission' => 'Edit Profile via web', 'description' => 'Allow user to edit profile via web.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'edit-profile-api', 'permission' => 'Edit Profile via API', 'description' => 'Allow user to edit profile via API.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'system-info', 'permission' => 'View System Information', 'description' => 'View system information.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'user-list', 'permission' => 'List Users', 'description' => 'List users.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'user-info', 'permission' => 'View User Info', 'description' => 'View user information.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'user-add', 'permission' => 'Add User', 'description' => 'Add user.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'user-edit', 'permission' => 'Edit User', 'description' => 'Edit user.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'user-delete', 'permission' => 'Delete User', 'description' => 'Delete user.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'role-list', 'permission' => 'List Roles', 'description' => 'List roles.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'role-info', 'permission' => 'View Role Info', 'description' => 'View role information.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'role-add', 'permission' => 'Add Role', 'description' => 'Add role.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'role-edit', 'permission' => 'Edit Role', 'description' => 'Edit role.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'role-delete', 'permission' => 'Delete Role', 'description' => 'Delete role.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'permission-list', 'permission' => 'List Permissions', 'description' => 'List permissions.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'permission-info', 'permission' => 'View Permission Info', 'description' => 'View permission information.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'permission-add', 'permission' => 'Add Permission', 'description' => 'Add permission.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'permission-edit', 'permission' => 'Edit Permission', 'description' => 'Edit permission.', 'is_default' => 0, 'is_readonly' => 1]);
Permission::create(['name' => 'permission-delete', 'permission' => 'Delete Permission', 'description' => 'Delete permission.', 'is_default' => 0, 'is_readonly' => 1]);
}
示例13: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$permission = Permission::create(['permission_name' => $request->get('permission_name'), 'permission_slug' => $request->get('permission_slug')]);
Flash::success('The role "' . $permission->permission_name . '"" was successfully created.');
return back();
}
示例14: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
////////////////////////////////////
// Load the routes
Route::loadLaravelRoutes();
// Look for and delete route named 'do-not-load' if it exist.
// That route is used to test the Authorization middleware and should not be loaded automatically.
$routeToDelete = Route::where('name', 'do-not-load')->get()->first();
if ($routeToDelete) {
Route::destroy($routeToDelete->id);
}
////////////////////////////////////
// Create basic set of permissions
$permGuestOnly = Permission::create(['name' => 'guest-only', 'display_name' => 'Guest only access', 'description' => 'Only guest users can access these.', 'enabled' => true]);
$permOpenToAll = Permission::create(['name' => 'open-to-all', 'display_name' => 'Open to all', 'description' => 'Everyone can access these, even unauthenticated (guest) users.', 'enabled' => true]);
$permBasicAuthenticated = Permission::create(['name' => 'basic-authenticated', 'display_name' => 'Basic authenticated', 'description' => 'Basic permission after being authenticated.', 'enabled' => true]);
// Create a few permissions for the admin|security section
$permManageMenus = Permission::create(['name' => 'manage-menus', 'display_name' => 'Manage menus', 'description' => 'Allows a user to manage the site menus.', 'enabled' => true]);
$permManageUsers = Permission::create(['name' => 'manage-users', 'display_name' => 'Manage users', 'description' => 'Allows a user to manage the site users.', 'enabled' => true]);
$permManageRoles = Permission::create(['name' => 'manage-roles', 'display_name' => 'Manage roles', 'description' => 'Allows a user to manage the site roles.', 'enabled' => true]);
$permManagePermissions = Permission::create(['name' => 'manage-permissions', 'display_name' => 'Manage permissions', 'description' => 'Allows a user to manage the site permissions.', 'enabled' => true]);
$permManageRoutes = Permission::create(['name' => 'manage-routes', 'display_name' => 'Manage routes', 'description' => 'Allows a user to Manage the site routes.', 'enabled' => true]);
// Create a few permissions for the admin|audit section
$permAuditLogView = Permission::create(['name' => 'audit-log-view', 'display_name' => 'View audit log', 'description' => 'Allows a user to view the audit log.', 'enabled' => true]);
$permAuditReplay = Permission::create(['name' => 'audit-log-replay', 'display_name' => 'Replay audit log item', 'description' => 'Allows a user to replay items from the audit log.', 'enabled' => true]);
$permAuditPurge = Permission::create(['name' => 'audit-log-purge', 'display_name' => 'Purge audit log', 'description' => 'Allows a user to purge old items from the audit log.', 'enabled' => true]);
$permAdminSettings = Permission::create(['name' => 'admin-settings', 'display_name' => 'Administer site settings', 'description' => 'Allows a user to change site settings.', 'enabled' => true]);
////////////////////////////////////
// Associate open-to-all permission to some routes
$routeBackslash = Route::where('name', 'backslash')->get()->first();
$routeBackslash->permission()->associate($permOpenToAll);
$routeBackslash->save();
$routeHome = Route::where('name', 'home')->get()->first();
$routeHome->permission()->associate($permOpenToAll);
$routeHome->save();
$routeFaust = Route::where('name', 'faust')->get()->first();
$routeFaust->permission()->associate($permOpenToAll);
$routeFaust->save();
// Associate basic-authenticated permission to the dashboard route
$routeDashboard = Route::where('name', 'dashboard')->get()->first();
$routeDashboard->permission()->associate($permBasicAuthenticated);
$routeDashboard->save();
// Associate the audit-log permissions
$routeAuditView = Route::where('name', 'admin.audit.index')->get()->first();
$routeAuditView->permission()->associate($permAuditLogView);
$routeAuditView->save();
$routeAuditShow = Route::where('name', 'admin.audit.show')->get()->first();
$routeAuditShow->permission()->associate($permAuditLogView);
$routeAuditShow->save();
$routeAuditPurge = Route::where('name', 'admin.audit.purge')->get()->first();
$routeAuditPurge->permission()->associate($permAuditPurge);
$routeAuditPurge->save();
$routeAuditReplay = Route::where('name', 'admin.audit.replay')->get()->first();
$routeAuditReplay->permission()->associate($permAuditReplay);
$routeAuditReplay->save();
// Associate manage-menus permissions to routes starting with 'admin.menus.'
$manageMenusRoutes = Route::where('name', 'like', "admin.menus.%")->get()->all();
foreach ($manageMenusRoutes as $route) {
$route->permission()->associate($permManageMenus);
$route->save();
}
// Associate manage-permission permissions to routes starting with 'admin.permissions.'
$managePermRoutes = Route::where('name', 'like', "admin.permissions.%")->get()->all();
foreach ($managePermRoutes as $route) {
$route->permission()->associate($permManagePermissions);
$route->save();
}
// Associate manage-roles permissions to routes starting with 'admin.roles.'
$manageRoleRoutes = Route::where('name', 'like', "admin.roles.%")->get()->all();
foreach ($manageRoleRoutes as $route) {
$route->permission()->associate($permManageRoles);
$route->save();
}
// Associate manage-routes permissions to routes starting with 'admin.routes.'
$manageRouteRoutes = Route::where('name', 'like', "admin.routes.%")->get()->all();
foreach ($manageRouteRoutes as $route) {
$route->permission()->associate($permManageRoutes);
$route->save();
}
// Associate manage-users permissions to routes starting with 'admin.users.'
$manageUserRoutes = Route::where('name', 'like', "admin.users.%")->get()->all();
foreach ($manageUserRoutes as $route) {
$route->permission()->associate($permManageUsers);
$route->save();
}
// Associate the admin-settings permissions
$routeAdminSettings = Route::where('name', 'admin.settings.index')->get()->first();
$routeAdminSettings->permission()->associate($permAdminSettings);
$routeAdminSettings->save();
////////////////////////////////////
// Create role: admins
$roleAdmins = Role::create(["name" => "admins", "display_name" => "Administrators", "description" => "Administrators have no restrictions", "enabled" => true]);
// Create role: users
// Assign permission basic-authenticated
$roleUsers = Role::create(["name" => "users", "display_name" => "Users", "description" => "All authenticated users", "enabled" => true]);
//.........这里部分代码省略.........
示例15: run
public function run()
{
/**
| The Super Admin Role.
*/
$superAdminRole = Role::create(['name' => 'super_admin', 'label' => 'Super Administrator', 'visible' => false]);
/**
| The Can Access Dashboard Role.
| Can access to the dashboard.
*/
$dashboardRole = Role::create(['name' => 'dashboard', 'label' => 'Dashboard']);
/**
| The Manage Roles Role.
| Can manage and handle the Roles.
*/
$manageRoles = Role::create(['name' => 'manage_roles', 'label' => 'Manage Roles']);
/**
| The Manage Users Role.
| Can manage and handle the Users.
*/
$manageUsers = Role::create(['name' => 'manage_users', 'label' => 'Manage Users']);
/**
| The File Browser Role.
| Can upload and manage files.
*/
$fileBrowser = Role::create(['name' => 'file-browser', 'label' => 'File Browser']);
/**
| Permission to be assigned to the Manage Role Role.
*/
$canAccessDashboardPermission = Permission::create(['name' => 'dashboard', 'label' => 'Dashboard']);
/**
| Permission to be assigned to the Manage Role Role.
*/
$readRole = Permission::create(['name' => 'read_roles', 'label' => 'Read roles']);
$createRole = Permission::create(['name' => 'create_roles', 'label' => 'Create roles']);
$updateRole = Permission::create(['name' => 'update_roles', 'label' => 'Update roles']);
$deleteRole = Permission::create(['name' => 'delete_roles', 'label' => 'Delete roles']);
/**
| Permission to be assigned to the Manager Permissions Role.
*/
$readPermission = Permission::create(['name' => 'read_permissions', 'label' => 'Read permissions', 'visible' => false]);
$createPermission = Permission::create(['name' => 'create_permissions', 'label' => 'Create permissions', 'visible' => false]);
$updatePermission = Permission::create(['name' => 'update_permissions', 'label' => 'Update permissions', 'visible' => false]);
$deletePermission = Permission::create(['name' => 'delete_permissions', 'label' => 'Delete permissions', 'visible' => false]);
/**
| Permission to be assigned to the Manage Users Role.
*/
$readUsers = Permission::create(['name' => 'read_users', 'label' => 'Read users']);
$createUsers = Permission::create(['name' => 'create_users', 'label' => 'Create users']);
$updateUsers = Permission::create(['name' => 'update_users', 'label' => 'Update users']);
$deleteUsers = Permission::create(['name' => 'delete_users', 'label' => 'Delete users']);
/**
| Permission to be assigned to the Manage Files Role.
*/
$readFile = Permission::create(['name' => 'read_files', 'label' => 'Read files']);
$uploadFile = Permission::create(['name' => 'upload_files', 'label' => 'Upload files']);
$updateFile = Permission::create(['name' => 'update_files', 'label' => 'Update files']);
$deleteFile = Permission::create(['name' => 'delete_files', 'label' => 'Delete files']);
/**
| Give Permission to Super Admin Role
*/
$superAdminRole->givePermissionTo($canAccessDashboardPermission);
$superAdminRole->givePermissionTo($readPermission);
$superAdminRole->givePermissionTo($createPermission);
$superAdminRole->givePermissionTo($updatePermission);
$superAdminRole->givePermissionTo($deletePermission);
$superAdminRole->givePermissionTo($readRole);
$superAdminRole->givePermissionTo($createRole);
$superAdminRole->givePermissionTo($updateRole);
$superAdminRole->givePermissionTo($deleteRole);
$superAdminRole->givePermissionTo($readUsers);
$superAdminRole->givePermissionTo($createUsers);
$superAdminRole->givePermissionTo($updateUsers);
$superAdminRole->givePermissionTo($deleteUsers);
$superAdminRole->givePermissionTo($readFile);
$superAdminRole->givePermissionTo($uploadFile);
$superAdminRole->givePermissionTo($updateFile);
$superAdminRole->givePermissionTo($deleteFile);
// Give Permissions to Roles
// Dashboard
$dashboardRole->givePermissionTo($canAccessDashboardPermission);
// Give Permissions to Roles
// Roles
$manageRoles->givePermissionTo($readRole);
$manageRoles->givePermissionTo($createRole);
$manageRoles->givePermissionTo($updateRole);
$manageRoles->givePermissionTo($deleteRole);
// Give Permissions to Roles
// Users
$manageUsers->givePermissionTo($readUsers);
$manageUsers->givePermissionTo($createUsers);
$manageUsers->givePermissionTo($updateUsers);
$manageUsers->givePermissionTo($deleteUsers);
// Give Permissions to Roles
// Files
$fileBrowser->givePermissionTo($readFile);
$fileBrowser->givePermissionTo($uploadFile);
$fileBrowser->givePermissionTo($updateFile);
$fileBrowser->givePermissionTo($deleteFile);
/**
//.........这里部分代码省略.........