tongshanglei лет назад: 2
Родитель
Сommit
7d08354c18
2 измененных файлов с 12 добавлено и 4 удалено
  1. 3 4
      catch/device/model/Station.php
  2. 9 0
      catch/device/model/get/StationGet.php

+ 3 - 4
catch/device/model/Station.php

@@ -55,8 +55,8 @@ class Station extends Model
     public function getAllList(){
         $res = $this
             ->catchSearch()
-            ->field('mac,name,latitude,longitude,online_time')
-            ->append(['is_online'])
+            // ->field('mac,name,latitude,longitude,online_time')
+            ->append(['is_online_text','is_online'])
             ->select();
             
         return $res;
@@ -86,8 +86,7 @@ class Station extends Model
         }elseif($value=='2'){
             return $query->where(function ($query) use( $time) {
                 $query->whereOr('online_time','<', $time)->whereOr('online_time','=', null);
-             });
-            // return $query->where('online_time', '>=', $time);
+            });
         }
         
     }

+ 9 - 0
catch/device/model/get/StationGet.php

@@ -29,5 +29,14 @@ trait StationGet
             return '1';
         }
     }
+    public function getIsOnlineTextAttr($value){
+        $value = strtotime($this->online_time);
+        $int=time()-$value;
+        if($int>300){
+            return '离线';
+        }else{
+            return '在线';
+        }
+    }
  
 }