當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Role::perms方法代碼示例

本文整理匯總了PHP中app\Role::perms方法的典型用法代碼示例。如果您正苦於以下問題:PHP Role::perms方法的具體用法?PHP Role::perms怎麽用?PHP Role::perms使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Role的用法示例。


在下文中一共展示了Role::perms方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: postCreate

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate(Request $request)
 {
     // Declare the rules for the form validation
     $rules = array('name' => 'required|unique:roles', 'display_name' => 'required|unique:roles');
     // Validate the inputs
     $validator = Validator::make($request->all(), $rules, ['name.required' => 'A name is required.', 'name.unique' => 'Please use a different name.', 'display_name.required' => 'A display name is required', 'display_name.unique' => 'Please use a different display name.']);
     // Check if the form validates with success
     if ($validator->passes()) {
         // Get the inputs, with some exceptions
         $inputs = $request->except('csrf_token');
         $this->role->name = $request->input('name');
         $this->role->display_name = $request->input('display_name');
         $this->role->is_protected = $request->has('is_protected') ? 1 : 0;
         $this->role->is_superuser = $request->has('is_superuser') ? 1 : 0;
         $this->role->save();
         // Save permissions
         $this->role->perms()->sync($this->permission->preparePermissionsForSave($inputs['permissions']));
         // Was the role created?
         if ($this->role->id) {
             // Redirect to the new role page
             Flash::success('Created role');
             return redirect('admin/roles/' . $this->role->id . '/edit');
         }
         // Redirect to the new role page
         Flash::error('Could not create role');
         return redirect('admin/roles/create');
     }
     // Form validation failed
     return redirect('admin/roles/create')->withInput()->withErrors($validator);
 }
開發者ID:fetch404,項目名稱:fetch404,代碼行數:35,代碼來源:AdminRolesController.php

示例2: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // Inserts the Permissions
     Permission::insert($this->permissions);
     // Creates a root admin role
     $rootadmin = new Role();
     $rootadmin->name = "rootadmin";
     $rootadmin->display_name = "Root Admin";
     $rootadmin->description = "Has Permissions to do everything in the WebPanel";
     $rootadmin->save();
     //Get all permissions
     $ids = Permission::lists('id')->all();
     //Sync them to the rootadmin
     $rootadmin->perms()->sync($ids);
     //Creates an admin user
     $admin = new User();
     $admin->name = 'admin';
     $admin->email = 'admin@admin.com';
     $admin->password = bcrypt('password');
     $admin->save();
     $admin->roles()->sync(array($rootadmin->id));
 }
開發者ID:brucewu16899,項目名稱:WebPanel-Core,代碼行數:27,代碼來源:2015_05_20_000000_webpanel_add_permissions_roles.php

示例3: run

 public function run()
 {
     /* Create administrator role */
     $admin = new Role();
     $admin->name = 'Administrator';
     $admin->save();
     /* Create officer role */
     $officer = new Role();
     $officer->name = 'Officer';
     $officer->save();
     /* Create member role */
     $member = new Role();
     $member->name = 'Member';
     $member->save();
     /* Permissions */
     /* Default permission for board members */
     $manageSystem = new Permission();
     $manageSystem->name = 'manage_system';
     $manageSystem->display_name = 'Manage System';
     $manageSystem->save();
     /* Apply permissions */
     $admin->perms()->sync(array($manageSystem->id));
     $officer->perms()->sync(array($manageSystem->id));
 }
開發者ID:natalieduong,項目名稱:konnection,代碼行數:24,代碼來源:EntrustSeeder.php

示例4: setupFounderAndBaseRolesPermission

 /**
  *  Initialize the user group
  *
  */
 public function setupFounderAndBaseRolesPermission()
 {
     //Create Roles
     $founder = new Role();
     $founder->name = 'Founder';
     $founder->save();
     $admin = new Role();
     $admin->name = 'Admin';
     $admin->save();
     //Create User
     $user = new User();
     $user->name = 'muzhuang';
     $user->email = 'admin@admin.com';
     $user->password = Hash::make('secret');
     if (!$user->save()) {
         Log::info('Unabel to create user ' . $user->username, (array) $user->errors());
     } else {
         Log::info('Create user "' . $user->username . '" <' . $user->email . '>');
     }
     //Attach Roles to user
     $user->roles()->attach($founder->id);
     //Create Permissions
     $manageUsers = new Permission();
     $manageUsers->name = 'admin.user';
     $manageUsers->display_name = 'Manage Users';
     $manageUsers->save();
     // Assign Permission to Role
     $founder->perms()->sync([$manageUsers->id]);
     $admin->perms()->sync([$manageUsers->id]);
 }
開發者ID:nutsdo,項目名稱:mz-service,代碼行數:34,代碼來源:2015_03_07_085330_entrust_setup_tables.php

示例5: remove_permissions_from_role

 private function remove_permissions_from_role(Role $role)
 {
     $role->perms()->sync(array());
 }
開發者ID:brucewu16899,項目名稱:WebPanel-Core,代碼行數:4,代碼來源:PermissionsTest.php

示例6: currentPerms

 /**
  * Get list current permission of Role
  * @var Role $role
  * @return array
  */
 public function currentPerms(Role $role)
 {
     $perms = $role->perms()->lists('id');
     return $perms->toArray();
 }
開發者ID:vnzacky,項目名稱:dog,代碼行數:10,代碼來源:EloquentRoleRepository.php

示例7: SyncPermissions

 /**
  * Sync the Server List
  *
  * @param Role $role
  * @param array $permissions
  */
 private function SyncPermissions(Role $role, $permissions = array())
 {
     if ($permissions == null) {
         $permissions = array();
     }
     $role->perms()->sync($permissions);
 }
開發者ID:brucewu16899,項目名稱:WebPanel-Core,代碼行數:13,代碼來源:RolesController.php

示例8: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  App\Role $role
  * @return Response
  */
 public function edit($role)
 {
     $current_permissions = array_pluck($role->perms()->get(['permissions.id'])->toArray(), 'id');
     return view('templates.' . \Config::get('webpanel.template') . 'webpanel.panel.roles.edit', compact('role', 'current_permissions'));
 }
開發者ID:brucewu16899,項目名稱:WebPanel-Core,代碼行數:11,代碼來源:RolesController.php


注:本文中的app\Role::perms方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。