src/System/Controllers/RoleController.php
private function _saveRolePermissions($request, $role)
    {
        $permissionIds = [];

        if (count($request->get('permissions')) > 0) {
            foreach ($request->get('permissions') as $key => $value) {
                if ($value != 1) {
                    continue;
                }
                $permissions = explode(',', $key);
                foreach ($permissions as $permissionName) {
                    if (null === ($permissionModel = Permission::getPermissionByName($permissionName))) {
                        $permissionModel = Permission::create(['name' => $permissionName]);
                    }
                    $permissionIds[] = $permissionModel->id;
                }
            }
        }
        $ids = array_unique($permissionIds);
        $role->permissions()->sync($ids);
    }
private function _saveRolePermissions($request, $role)
    {
        $permissionIds = [];

        if (count($request->get('permissions')) > 0) {
            foreach ($request->get('permissions') as $key => $value) {
                if ($value != 1) {
                    continue;
                }
                $permissions = explode(',', $key);
                foreach ($permissions as $permissionName) {
                    if (null === ($permissionModel = Permission::getPermissionByName($permissionName))) {
                        $permissionModel = Permission::create(['name' => $permissionName]);
                    }
                    $permissionIds[] = $permissionModel->id;
                }
            }
        }
        $ids = array_unique($permissionIds);
        $role->permissions()->sync($ids);
    }
private function _saveRolePermissions ( $ request , $ role ) { $ permissionIds = [ ] ; if ( count ( $ request -> get ( 'permissions' ) ) > 0 ) { foreach ( $ request -> get ( 'permissions' ) as $ key => $ value ) { if ( $ value != 1 ) { continue ; } $ permissions = explode ( ',' , $ key ) ; foreach ( $ permissions as $ permissionName ) { if ( null === ( $ permissionModel = Permission :: getPermissionByName ( $ permissionName ) ) ) { $ permissionModel = Permission :: create ( [ 'name' => $ permissionName ] ) ; } $ permissionIds [ ] = $ permissionModel -> id ; } } } $ ids = array_unique ( $ permissionIds ) ; $ role -> permissions ( ) -> sync ( $ ids ) ; }
Save Role Permission for the Users

@param \AvoRed\Framework\System\Requests\RoleRequest $request
@param \AvoRed\Framework\Models\Database\Role $rolet

@return void
Save Role Permission for the Users