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


PHP Role::assignPermission方法代码示例

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


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

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $superuser_role = new Role();
     $superuser_role->name = 'superuser';
     $superuser_role->label = "Super User";
     $superuser_role->save();
     $admin_role = new Role();
     $admin_role->name = 'admin';
     $admin_role->label = 'System Administrator';
     $admin_role->save();
     $tech_role = new Role();
     $tech_role->name = 'tech';
     $tech_role->label = 'Technician';
     $tech_role->save();
     $supportrep_role = new Role();
     $supportrep_role->name = 'supportrep';
     $supportrep_role->label = 'Customer Support Rep';
     $supportrep_role->save();
     $manage_users_permission = new Permission();
     $manage_users_permission->name = 'manage_users';
     $manage_users_permission->label = 'Manage Users';
     $manage_users_permission->save();
     $manage_customers_permission = new Permission();
     $manage_customers_permission->name = 'manage_customers';
     $manage_customers_permission->label = 'Manage Customers';
     $manage_customers_permission->save();
     $manage_monitoring_permission = new Permission();
     $manage_monitoring_permission->name = 'manage_monitoring';
     $manage_monitoring_permission->label = 'Manage Monitoring';
     $manage_monitoring_permission->save();
     $manage_switches_permission = new Permission();
     $manage_switches_permission->name = 'manage_switches';
     $manage_switches_permission->label = 'Manage Switches';
     $manage_switches_permission->save();
     $manage_dhcp_permission = new Permission();
     $manage_dhcp_permission->name = 'manage_dhcp';
     $manage_dhcp_permission->label = 'Manage DHCP';
     $manage_dhcp_permission->save();
     $manage_onts_permission = new Permission();
     $manage_onts_permission->name = 'manage_onts';
     $manage_onts_permission->label = 'Manage ONTs';
     $manage_onts_permission->save();
     $view_logs_permission = new Permission();
     $view_logs_permission->name = 'view_logs';
     $view_logs_permission->label = 'View Logs';
     $view_logs_permission->save();
     $manage_adminsettings_permission = new Permission();
     $manage_adminsettings_permission->name = 'manage_adminsettings';
     $manage_adminsettings_permission->label = 'Manage Admin Settings';
     $manage_adminsettings_permission->save();
     $superuser_role->assignPermission($manage_users_permission->name);
     $superuser_role->assignPermission($manage_customers_permission->name);
     $superuser_role->assignPermission($manage_monitoring_permission->name);
     $superuser_role->assignPermission($manage_switches_permission->name);
     $superuser_role->assignPermission($manage_dhcp_permission->name);
     $superuser_role->assignPermission($manage_onts_permission->name);
     $superuser_role->assignPermission($view_logs_permission->name);
     $superuser_role->assignPermission($manage_adminsettings_permission->name);
     $adminuser = new User();
     $adminuser->name = 'Goldfield Telecom';
     $adminuser->email = 'support@goldtelecom.com';
     $adminuser->password = bcrypt('1qaz2wsx');
     $adminuser->save();
     $adminuser->assignRole('superuser');
     $goatuser = new User();
     $goatuser->name = 'Ryan Gray';
     $goatuser->email = 'rgray@goldtelecom.com';
     $goatuser->password = bcrypt('1q2w3e4r');
     $goatuser->save();
     $goatuser->assignRole('superuser');
 }
开发者ID:goatatwork,项目名称:access2,代码行数:76,代码来源:UsersRolesPermissionsSeeder.php

示例2: apiAddPermissionToRole

 /**
  * 
  */
 public function apiAddPermissionToRole(Role $role, $permission)
 {
     return $role->assignPermission($permission);
 }
开发者ID:goatatwork,项目名称:goatshark,代码行数:7,代码来源:UsersController.php


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