tongshanglei 2 년 전
부모
커밋
9154362d18
2개의 변경된 파일31개의 추가작업 그리고 1개의 파일을 삭제
  1. 30 0
      catch/device/model/Station.php
  2. 1 1
      catch/device/model/get/StationGet.php

+ 30 - 0
catch/device/model/Station.php

@@ -61,6 +61,36 @@ class Station extends Model
             
         return $res;
     }
+    /**
+     * 根据名称搜索
+     */
+    public function searchNameAttr($query, $value, $data)
+    {
+        return $query->where('name', 'like', '%'.$value.'%');
+    }
+    /**
+     * 根据编号搜索
+     */
+    public function searchShortCodeAttr($query, $value, $data)
+    {
+        return $query->where('shortcode|mac', 'like', '%'.$value.'%');
+    }
+    /**
+     * 根据状态搜索
+     */
+    public function searchOnlineStateAttr($query, $value, $data)
+    {
+        $time=date('Y-m-d H:i:s',time()-300);
+        if($value=='1'){
+            return $query->where('online_time', '>=', $time);
+        }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);
+        }
+        
+    }
   
     
 }

+ 1 - 1
catch/device/model/get/StationGet.php

@@ -23,7 +23,7 @@ trait StationGet
     public function getIsOnlineAttr($value){
         $value = strtotime($this->online_time);
         $int=time()-$value;
-        if($int>180){
+        if($int>300){
             return '0';
         }else{
             return '1';