示例#1
0
 /**
  * Save User Permission into acl_user_permissions
  */
 public static function saveUserPermission($userId, $data = array())
 {
     UserPermissions::where('user_id', '=', $userId)->delete();
     foreach ($data as $key => $val) {
         if ($val != "" || $val != null) {
             $userpermission = new UserPermissions();
             $userpermission->user_id = $userId;
             $userpermission->permission_id = $key;
             $userpermission->value = $val;
             $userpermission->date_created = new DateTime();
             $userpermission->save();
         }
     }
 }
 public function updatepermission($id)
 {
     if (ACL::checkUserPermission('user.permission') == false) {
         return Redirect::action('dashboard');
     }
     if (Input::has('permission')) {
         $permission = Input::get('permission');
         $userpermission = ACL::saveUserPermission($id, $permission);
     } else {
         UserPermissions::where('user_id', '=', $id)->delete();
     }
     $message = 'User Permission has been modified';
     return Redirect::action('')->with('success', $message);
 }