rabin hai 3 meses
pai
achega
311ca7cb9e
Modificáronse 2 ficheiros con 10 adicións e 10 borrados
  1. 4 4
      lib/Code.php
  2. 6 6
      lib/Relation.php

+ 4 - 4
lib/Code.php

@@ -7,7 +7,7 @@ class Code
     # 获取邀请码
     public function get($uid)
     {   
-        $info = Dever::db('code', 'invite')->find(array('uid' => $uid));
+        $info = Dever::db('code', 'invite')->find(['uid' => $uid]);
         if ($info) {
             return $info['value'];
         } else {
@@ -19,12 +19,12 @@ class Code
 
     private function createCode($uid, $code)
     {
-        $info = Dever::db('code', 'invite')->find(array('value' => $code));
+        $info = Dever::db('code', 'invite')->find(['value' => $code]);
         if ($info) {
             $code = Str::rand(5, 0);
             return $this->createCode($uid, $code);
         } else {
-            Dever::db('code', 'invite')->insert(array('value' => $code, 'uid' => $uid));
+            Dever::db('code', 'invite')->insert(['value' => $code, 'uid' => $uid]);
             return $code;
         }
     }
@@ -32,7 +32,7 @@ class Code
     # 根据邀请码获取邀请人uid
     public function getUid($code)
     {   
-        $info = Dever::db('code', 'invite')->find(array('value' => $code));
+        $info = Dever::db('code', 'invite')->find(['value' => $code]);
         if ($info) {
             return $info['uid'];
         }

+ 6 - 6
lib/Relation.php

@@ -43,9 +43,9 @@ class Relation
     # 更换上级
     public function replaceParent($uid, $old_parent, $new_parent, $call = true)
     {
-        $info = Dever::db($this->table)->find(array('to_uid' => $uid, 'uid' => $old_parent));
+        $info = Dever::db($this->table)->find(['to_uid' => $uid, 'uid' => $old_parent]);
         if ($info) {
-            $state = Dever::db($this->table)->update($info['id'], array('uid' => $new_parent));
+            $state = Dever::db($this->table)->update($info['id'], ['uid' => $new_parent]);
             if ($state && $call) {
                 $child = $this->getChild($uid, false, false);
                 if ($child) {
@@ -61,7 +61,7 @@ class Relation
     # 重置上级
     public function resetParent($uid, $parent)
     {
-        Dever::db($this->table)->delete(array('to_uid' => $uid));
+        Dever::db($this->table)->delete(['to_uid' => $uid]);
         $this->set($parent, $uid);
 
         $child = $this->getChild($uid, 1, false);
@@ -76,13 +76,13 @@ class Relation
     # 清理邀请关系
     public function dropParent($uid, $parent)
     {
-        return Dever::db($this->table)->delete(array('to_uid' => $uid, 'uid' => $parent));
+        return Dever::db($this->table)->delete(['to_uid' => $uid, 'uid' => $parent]);
     }
 
     # 获取某个用户的上级数据
     public function getParent($uid, $level = 1)
     {
-        return Dever::db($this->table)->find(array('to_uid' => $uid, 'level' => $level));
+        return Dever::db($this->table)->find(['to_uid' => $uid, 'level' => $level]);
     }
 
     # 获取某个用户的所有上级数据
@@ -102,7 +102,7 @@ class Relation
         if ($level) {
             $where['level'] = $level;
         }
-        $set = array();
+        $set = [];
         if ($page) {
             $set['num'] = $page;
         }