tongshanglei 2 년 전
부모
커밋
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 '在线';
+        }
+    }
  
 }