作者 root

gx

@@ -18,16 +18,26 @@ class Base extends Model @@ -18,16 +18,26 @@ class Base extends Model
18 public function lists($map, $p, $row, $order = 'id', $fields = ['*']){ 18 public function lists($map, $p, $row, $order = 'id', $fields = ['*']){
19 //TODO::where(['id'=>'','name'=>'']) 19 //TODO::where(['id'=>'','name'=>''])
20 $lists = $this->select($fields)->where($map)->forPage($p,$row)->orderBy($order)->get(); 20 $lists = $this->select($fields)->where($map)->forPage($p,$row)->orderBy($order)->get();
21 - if (!empty($lists)) { 21 + if ($lists->isEmpty() === false) {
22 $lists = $lists->toArray(); 22 $lists = $lists->toArray();
23 - $this->allCount = DB::table($this->table)->where($map)->count(); 23 + $this->allCount = $this->where($map)->count();
24 } 24 }
25 return $lists; 25 return $lists;
26 } 26 }
27 27
  28 +
  29 + /**
  30 + * @param $map
  31 + * @param $order
  32 + * @param $fields
  33 + * @name :无分页列表
  34 + * @return mixed
  35 + * @author :liyuhang
  36 + * @method
  37 + */
28 public function list($map,$order = 'id',$fields = ['*']){ 38 public function list($map,$order = 'id',$fields = ['*']){
29 $lists = $this->select($fields)->where($map)->orderBy($order)->get(); 39 $lists = $this->select($fields)->where($map)->orderBy($order)->get();
30 - if (!empty($lists)) { 40 + if ($lists->isEmpty() === false) {
31 $lists = $lists->toArray(); 41 $lists = $lists->toArray();
32 } 42 }
33 return $lists; 43 return $lists;
@@ -41,10 +51,14 @@ class Base extends Model @@ -41,10 +51,14 @@ class Base extends Model
41 */ 51 */
42 public function read($condition,$files = ['*']) 52 public function read($condition,$files = ['*'])
43 { 53 {
44 - $info = $this->select($files)->where($condition)->first()->toArray(); 54 + $info = $this->select($files)->where($condition)->first();
  55 + if (!empty($info)) {
  56 + $info = $info->toArray();
  57 + }
45 return $info; 58 return $info;
46 } 59 }
47 60
  61 +
48 /** 62 /**
49 * @name :新增 63 * @name :新增
50 * @return void 64 * @return void
@@ -52,8 +66,8 @@ class Base extends Model @@ -52,8 +66,8 @@ class Base extends Model
52 * @method post 66 * @method post
53 */ 67 */
54 public function add($data){ 68 public function add($data){
55 - $data['created_at'] = date('Y-m-d H:i:s',time());  
56 - $data['updated_at'] = date('Y-m-d H:i:s',time()); 69 +// $data['created_at'] = date('Y-m-d H:i:s',time());
  70 +// $data['updated_at'] = date('Y-m-d H:i:s',time());
57 return $this->insert($data); 71 return $this->insert($data);
58 } 72 }
59 73
@@ -67,7 +81,7 @@ class Base extends Model @@ -67,7 +81,7 @@ class Base extends Model
67 if(isset($data['id']) && !empty($data['id'])){ 81 if(isset($data['id']) && !empty($data['id'])){
68 unset($data['id']); 82 unset($data['id']);
69 } 83 }
70 - $data['updated_at'] = date('Y-m-d H:i:s',time()); 84 +// $data['updated_at'] = date('Y-m-d H:i:s',time());
71 return $this->where($condition)->update($data); 85 return $this->where($condition)->update($data);
72 } 86 }
73 87