Iot.php 393 B

1234567891011121314
  1. <?php
  2. namespace app\green\controller\home;
  3. use app\common\controller\Home;
  4. use app\green\model\GreenDevice;
  5. class Iot extends Home{
  6. public function index(){
  7. $list = GreenDevice::where(['state' => 0])->whereTime('update_time','<',time()-35)->select();
  8. foreach ($list as $device){
  9. GreenDevice::where(['id' => $device->id])->update(['state' => 1]);
  10. }
  11. }
  12. }