当前位置: 首页>>代码示例>>PHP>>正文


PHP Role::attachPermissions方法代码示例

本文整理汇总了PHP中app\Role::attachPermissions方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::attachPermissions方法的具体用法?PHP Role::attachPermissions怎么用?PHP Role::attachPermissions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Role的用法示例。


在下文中一共展示了Role::attachPermissions方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $user = new Role();
     $user->name = 'user';
     $user->display_name = 'User';
     $user->save();
     $admin = new Role();
     $admin->name = 'admin';
     $admin->display_name = 'System Administrator';
     $admin->save();
     $createProduct = new Permission();
     $createProduct->name = 'create-product';
     $createProduct->display_name = 'Create Product';
     $createProduct->save();
     $showProduct = new Permission();
     $showProduct->name = 'show-product';
     $showProduct->display_name = 'Show Product';
     $showProduct->save();
     $editProduct = new Permission();
     $editProduct->name = 'edit-product';
     $editProduct->display_name = 'Edit Product';
     $editProduct->save();
     $deleteProduct = new Permission();
     $deleteProduct->name = 'delete-product';
     $deleteProduct->display_name = 'Delete Product';
     $deleteProduct->save();
     $admin->attachPermissions(array($createProduct, $showProduct, $editProduct, $deleteProduct));
     $createCompany = new Permission();
     $createCompany->name = 'create-company';
     $createCompany->display_name = 'Create Company';
     $createCompany->save();
     $showCompany = new Permission();
     $showCompany->name = 'show-company';
     $showCompany->display_name = 'Show Company';
     $showCompany->save();
     $editCompany = new Permission();
     $editCompany->name = 'edit-company';
     $editCompany->display_name = 'Edit Company';
     $editCompany->save();
     $deleteCompany = new Permission();
     $deleteCompany->name = 'delete-company';
     $deleteCompany->display_name = 'Delete Company';
     $deleteCompany->save();
     $admin->attachPermissions(array($createCompany, $showCompany, $editCompany, $deleteCompany));
 }
开发者ID:Johca,项目名称:Order-Portal,代码行数:50,代码来源:2015_11_02_104146_create_roles_and_permissions.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(RoleRequest $request)
 {
     $role = new Role();
     $role->fill($request->all());
     $role->name = snake_case($request->display_name);
     $role->save();
     $role->attachPermissions($request->permissions);
     return redirect()->route('rol.index');
 }
开发者ID:ericray,项目名称:gas,代码行数:15,代码来源:RoleController.php

示例3: create

 /**
  * @param $input
  * @param $permissions
  * @return bool
  * @throws GeneralException
  */
 public function create($input, $permissions)
 {
     if (Role::where('name', '=', $input['name'])->first()) {
         throw new GeneralException('That role already exists. Please choose a different name.');
     }
     //See if the role must contain a permission as per config
     if (config('access.roles.role_must_contain_permission') && count($permissions['role_permissions']) == 0) {
         throw new GeneralException('You must select at least one permission for this role.');
     }
     $role = new Role();
     $role->name = $input['name'];
     if ($role->save()) {
         //Attach permissions
         if (count($permissions['role_permissions']) > 0) {
             $role->attachPermissions($permissions['role_permissions']);
         }
         return true;
     }
     throw new GeneralException("There was a problem creating this role. Please try again.");
 }
开发者ID:num3thod,项目名称:laravel-5-boilerplate,代码行数:26,代码来源:EloquentRoleRepository.php

示例4: run


//.........这里部分代码省略.........
     $editUser->save();
     $showUser = new Permission();
     $showUser->name = 'show-users';
     $showUser->display_name = 'Show Users';
     $showUser->description = 'See full existing (non-public) user profiles and their full details';
     $showUser->save();
     $deleteUser = new Permission();
     $deleteUser->name = 'delete-users';
     $deleteUser->display_name = 'Delete Users';
     $deleteUser->description = 'Able to delete users';
     $deleteUser->save();
     $createMotion = new Permission();
     $createMotion->name = 'create-motions';
     $createMotion->display_name = 'Create Motion';
     $createMotion->description = 'Create and edit own motions';
     $createMotion->save();
     $editMotion = new Permission();
     $editMotion->name = "administrate-motions";
     $editMotion->display_name = 'Administrate Motion';
     $editMotion->description = 'Administrate existing motions, enable them';
     $editMotion->save();
     $showMotion = new Permission();
     $showMotion->name = "show-motions";
     $showMotion->display_name = 'Show Motion';
     $showMotion->description = 'Show all non-active motions';
     $showMotion->save();
     $deleteMotion = new Permission();
     $deleteMotion->name = "delete-motions";
     $deleteMotion->display_name = 'Delete Motion';
     $deleteMotion->description = 'Delete motions';
     $deleteMotion->save();
     $createComment = new Permission();
     $createComment->name = "create-comments";
     $createComment->display_name = 'Create a comment';
     $createComment->description = 'Create and edit own comment';
     $createComment->save();
     $viewComment = new Permission();
     $viewComment->name = "view-comments";
     $viewComment->display_name = 'View Comments';
     $viewComment->description = 'View the comments and owners of comments that are not public';
     $viewComment->save();
     $createCommentVote = new Permission();
     $createCommentVote->name = "create-comment_votes";
     $createCommentVote->display_name = 'Create Comments';
     $createCommentVote->description = 'Can vote on comments';
     $createCommentVote->save();
     $viewCommentVote = new Permission();
     $viewCommentVote->name = "view-comment_votes";
     $viewCommentVote->display_name = 'Create Comments';
     $viewCommentVote->description = 'Can view other users comment votes';
     $viewCommentVote->save();
     $deleteComment = new Permission();
     $deleteComment->name = "delete-comments";
     $deleteComment->display_name = 'Delete Comment';
     $deleteComment->description = 'Delete other peoples comments';
     $deleteComment->save();
     $createVote = new Permission();
     $createVote->name = "create-votes";
     $createVote->display_name = 'Can vote (Create a vote)';
     $createVote->description = 'Can vote, vote on a comment, can edit';
     $createVote->save();
     $showVote = new Permission();
     $showVote->name = "show-votes";
     $showVote->display_name = 'Can see other users votes';
     $showVote->description = 'Can see who placed a vote and a detailed record of all votes cast (like most recent vote)';
     $showVote->save();
     $createProperty = new Permission();
     $createProperty->name = "create-properties";
     $createProperty->display_name = 'Create Property';
     $createProperty->description = 'Can create a property';
     $createProperty->save();
     $editProperty = new Permission();
     $editProperty->name = "administrate-properties";
     $editProperty->display_name = 'Administrate Property';
     $editProperty->description = 'Can edit/delete a property';
     $editProperty->save();
     $createBackgroundImage = new Permission();
     $createBackgroundImage->name = "create-background_images";
     $createBackgroundImage->display_name = 'Create Background Image';
     $createBackgroundImage->description = 'Can create and upload a background image';
     $createBackgroundImage->save();
     $editBackgroundImage = new Permission();
     $editBackgroundImage->name = "administrate-background_images";
     $editBackgroundImage->display_name = 'Edit Background Image';
     $editBackgroundImage->description = 'Can activate and edit other background images';
     $editBackgroundImage->save();
     $createDepartment = new Permission();
     $createDepartment->name = "create-department";
     $createDepartment->display_name = 'Create Department';
     $createDepartment->description = 'Can create a department';
     $createDepartment->save();
     $editDepartment = new Permission();
     $editDepartment->name = "administrate-department";
     $editDepartment->display_name = 'Edit Department';
     $editDepartment->description = 'Can activate and departments';
     $editDepartment->save();
     $councillor->attachPermissions(array($createComment, $createVote, $createMotion, $editMotion, $createCommentVote, $viewCommentVote));
     $citizen->attachPermissions(array($createComment, $createVote, $createCommentVote, $createBackgroundImage));
     $admin->attachPermissions(array($editUser, $showUser, $deleteUser, $createComment, $createVote, $createMotion, $editMotion, $showMotion, $deleteMotion, $createProperty, $editProperty, $viewComment, $showVote, $createCommentVote, $viewCommentVote, $editPermission, $createBackgroundImage, $editBackgroundImage, $createDepartment, $editDepartment));
 }
开发者ID:vitz3,项目名称:IserveU,代码行数:101,代码来源:EntrustRoleTableSeeder.php

示例5: anyCreateRole


//.........这里部分代码省略.........
	$editcompany->description  = 'Cập nhật công ty'; // optional
	$editcompany->save();

	// Setting
	$viewsetting = new Permission();
	$viewsetting->name         = 'view-settings';
	$viewsetting->display_name = 'Truy cập bảng điều khiển'; // optional
	$viewsetting->description  = 'Truy cập bảng điều khiển'; // optional
	$viewsetting->save();

	//Công nợ
	$viewreceipt = new Permission();
	$viewreceipt->name         = 'view-receipts';
	$viewreceipt->display_name = 'Truy cập công nợ'; // optional
	$viewreceipt->description  = 'Truy cập công nợ'; // optional
	$viewreceipt->save();

	//Doanh thu
	$viewrevenue = new Permission();
	$viewrevenue->name         = 'view-revenues';
	$viewrevenue->display_name = 'Truy cập doanh thu'; // optional
	$viewrevenue->description  = 'Truy cập doanh thu'; // optional
	$viewrevenue->save();

	//Doanh thu
	$viewhistory = new Permission();
	$viewhistory->name         = 'view-historys';
	$viewhistory->display_name = 'Truy cập lịch sử'; // optional
	$viewhistory->description  = 'Truy cập lịch sử'; // optional
	$viewhistory->save();

	// Add permission to role

	$admin_role->attachPermissions(array(
						$createpo,
						$createso,
						$createrpo,
						$createrso,
						$completepo,
						$completeso,
						$completerpo,
						$completerso,
						$editpo,
						$editso,
						$editrpo,
						$editrso,
						$viewpo,
						$viewso,
						$viewrpo,
						$viewrso,
						$deletepo,
						$deleteso,
						$deleterpo,
						$deleterso,
						$createproduct,
						$deleteproduct,
						$sellpriceproduct,
						$viewproduct,
						$editproduct,
						$createcompany,
						$deletecompany,
						$viewcompany,
						$editcompany,
						$viewsetting,
						$viewreceipt,
						$viewrevenue,
开发者ID:kamitori,项目名称:khuongnhi2,代码行数:67,代码来源:SettingsController.php

示例6: add_permissions_to_role

 private function add_permissions_to_role(Role $role)
 {
     //Get the permissions and assign them to the Role
     $perm_str_itm_view = Permission::where('name', 'WebPanelStoreItemsView')->first();
     $perm_str_cat_view = Permission::where('name', 'WebPanelStoreCategoriesView')->first();
     $perm_str_usr_view = Permission::where('name', 'WebPanelStoreUsersView')->first();
     $perm_str_srv_view = Permission::where('name', 'WebPanelStoreServersView')->first();
     $perm_str_tol_view = Permission::where('name', 'WebPanelStoreToolsView')->first();
     $role->attachPermissions(array($perm_str_itm_view, $perm_str_cat_view, $perm_str_usr_view, $perm_str_srv_view, $perm_str_tol_view));
 }
开发者ID:brucewu16899,项目名称:WebPanel-Core,代码行数:10,代码来源:PermissionsTest.php

示例7: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //Create Roles
     $superadmin = new Role();
     $superadmin->name = 'superadmin';
     $superadmin->display_name = 'SuperAdmin';
     // optional
     $superadmin->description = 'Technical administrators: developers, webmins, etc';
     // optional
     $superadmin->save();
     $admin = new Role();
     $admin->name = 'admin';
     $admin->display_name = 'Admin';
     // optional
     $admin->description = 'Users with access to the administration panel';
     // optional
     $admin->save();
     //Create Permissions
     $view_admin_panel = new Permission();
     $view_admin_panel->name = 'view-admin-panel';
     $view_admin_panel->display_name = 'View Admin Panel';
     // optional
     $view_admin_panel->description = 'Access to the Admin Panel';
     // optional
     $view_admin_panel->save();
     $view_account_permissions = new Permission();
     $view_account_permissions->name = 'view-account-permissions';
     $view_account_permissions->display_name = 'View Account Permissions';
     // optional
     $view_account_permissions->description = 'Show some demo info on the Admin Dashboard';
     // optional
     $view_account_permissions->save();
     $use_file_manager = new Permission();
     $use_file_manager->name = 'use-file-manager';
     $use_file_manager->display_name = 'Use File Manager';
     // optional
     $use_file_manager->description = 'Access to upload/delete/edit files';
     // optional
     $use_file_manager->save();
     $view_backups = new Permission();
     $view_backups->name = 'view-backups';
     $view_backups->display_name = 'View Backups';
     // optional
     $view_backups->description = 'Access to the Backups Panel';
     // optional
     $view_backups->save();
     $make_backups = new Permission();
     $make_backups->name = 'make-backups';
     $make_backups->display_name = 'Make Backups';
     // optional
     $make_backups->description = 'Access to create new backups';
     // optional
     $make_backups->save();
     $download_backups = new Permission();
     $download_backups->name = 'download-backups';
     $download_backups->display_name = 'Download Backups';
     // optional
     $download_backups->description = 'Access to download existing backups';
     // optional
     $download_backups->save();
     $delete_backups = new Permission();
     $delete_backups->name = 'delete-backups';
     $delete_backups->display_name = 'Delete Backups';
     // optional
     $delete_backups->description = 'Access to delete existing backups';
     // optional
     $delete_backups->save();
     $view_logs = new Permission();
     $view_logs->name = 'view-logs';
     $view_logs->display_name = 'View Logs';
     // optional
     $view_logs->save();
     $download_logs = new Permission();
     $download_logs->name = 'download-logs';
     $download_logs->display_name = 'Download Logs';
     // optional
     $download_logs->save();
     $delete_logs = new Permission();
     $delete_logs->name = 'delete-logs';
     $delete_logs->display_name = 'Delete Logs';
     // optional
     $delete_logs->save();
     $preview_logs = new Permission();
     $preview_logs->name = 'preview-logs';
     $preview_logs->display_name = 'Preview Logs';
     // optional
     $preview_logs->save();
     $superadmin->attachPermissions(array($view_admin_panel, $view_account_permissions, $use_file_manager, $view_backups, $make_backups, $download_backups, $delete_backups, $view_logs, $download_logs, $delete_logs, $preview_logs));
     $admin->attachPermissions(array($view_admin_panel, $use_file_manager));
 }
开发者ID:Nikolay200669,项目名称:dick,代码行数:95,代码来源:EntrustTableSeeder.php

示例8: run


//.........这里部分代码省略.........
     $editMotion->display_name = 'Administrate Motion';
     $editMotion->description = 'Administrate existing motions, enable them';
     $editMotion->save();
     $showMotion = new Permission();
     $showMotion->name = "show-motions";
     $showMotion->display_name = 'Show Motion';
     $showMotion->description = 'Show all non-active motions';
     $showMotion->save();
     $deleteMotion = new Permission();
     $deleteMotion->name = "delete-motions";
     $deleteMotion->display_name = 'Delete Motion';
     $deleteMotion->description = 'Delete motions';
     $deleteMotion->save();
     $createComment = new Permission();
     $createComment->name = "create-comments";
     $createComment->display_name = 'Create a comment';
     $createComment->description = 'Create and edit own comment';
     $createComment->save();
     $viewComment = new Permission();
     $viewComment->name = "view-comments";
     $viewComment->display_name = 'View Comments';
     $viewComment->description = 'View the comments and owners of comments that are not public';
     $viewComment->save();
     $createCommentVote = new Permission();
     $createCommentVote->name = "create-comment_votes";
     $createCommentVote->display_name = 'Create Comments';
     $createCommentVote->description = 'Can vote on comments';
     $createCommentVote->save();
     $viewCommentVote = new Permission();
     $viewCommentVote->name = "view-comment_votes";
     $viewCommentVote->display_name = 'Create Comments';
     $viewCommentVote->description = 'Can view other users comment votes';
     $viewCommentVote->save();
     $deleteComment = new Permission();
     $deleteComment->name = "delete-comments";
     $deleteComment->display_name = 'Delete Comment';
     $deleteComment->description = 'Delete other peoples comments';
     $deleteComment->save();
     $createVote = new Permission();
     $createVote->name = "create-votes";
     $createVote->display_name = 'Can vote (Create a vote)';
     $createVote->description = 'Can vote, vote on a comment, can edit';
     $createVote->save();
     $showVote = new Permission();
     $showVote->name = "show-votes";
     $showVote->display_name = 'Can see other users votes';
     $showVote->description = 'Can see who placed a vote and a detailed record of all votes cast (like most recent vote)';
     $showVote->save();
     $createProperty = new Permission();
     $createProperty->name = "create-properties";
     $createProperty->display_name = 'Create Property';
     $createProperty->description = 'Can create a property';
     $createProperty->save();
     $editProperty = new Permission();
     $editProperty->name = "administrate-properties";
     $editProperty->display_name = 'Administrate Property';
     $editProperty->description = 'Can edit/delete a property';
     $editProperty->save();
     $createBackgroundImage = new Permission();
     $createBackgroundImage->name = "create-background_images";
     $createBackgroundImage->display_name = 'Create Background Image';
     $createBackgroundImage->description = 'Can create and upload a background image';
     $createBackgroundImage->save();
     $editBackgroundImage = new Permission();
     $editBackgroundImage->name = "administrate-background_images";
     $editBackgroundImage->display_name = 'Edit Background Image';
     $editBackgroundImage->description = 'Can activate and edit other background images';
     $editBackgroundImage->save();
     $createDepartment = new Permission();
     $createDepartment->name = "create-department";
     $createDepartment->display_name = 'Create Department';
     $createDepartment->description = 'Can create a department';
     $createDepartment->save();
     $editDepartment = new Permission();
     $editDepartment->name = "administrate-department";
     $editDepartment->display_name = 'Edit Department';
     $editDepartment->description = 'Can activate and departments';
     $editDepartment->save();
     $councilor->attachPermissions(array($createComment, $createVote, $createMotion, $editMotion));
     $citizen->attachPermissions(array($createComment, $createVote, $createCommentVote, $createBackgroundImage));
     $admin->attachPermissions(array($editUser, $showUser, $deleteUser, $createComment, $createVote, $createMotion, $editMotion, $showMotion, $deleteMotion, $createProperty, $editProperty, $viewComment, $showVote, $createCommentVote, $viewCommentVote, $editPermission, $createBackgroundImage, $editBackgroundImage, $createDepartment, $editDepartment));
     $userManager->attachPermissions(array($editUser, $showUser, $deleteUser));
     $unverified->attachPermissions(array($createComment, $createVote, $createCommentVote, $createBackgroundImage));
     $random_pass = 'abcd1234';
     //str_random(8);
     $defaultUser = new User();
     $this->command->info("\n\nADMIN LOGIN WITH: Password: (" . $random_pass . ") Email: info@iserveu.ca \n\n");
     $defaultUser->first_name = "Change";
     $defaultUser->middle_name = "";
     $defaultUser->last_name = "Name";
     $defaultUser->email = "info@iserveu.ca";
     $defaultUser->public = 1;
     $defaultUser->date_of_birth = "1987-04-01";
     $defaultUser->ethnic_origin_id = 1;
     $defaultUser->password = $random_pass;
     $defaultUser->save();
     $date = new DateTime();
     $date->add(new DateInterval('P3Y'));
     $defaultUser->attachRole($admin);
 }
开发者ID:dwoodard,项目名称:IserveU,代码行数:101,代码来源:DatabaseSeeder.php


注:本文中的app\Role::attachPermissions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。