<?php

namespace App\Admin\Actions\Box;

use App\Model\LockInfo;
use App\Server\DeviceServer;
use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;

class getRule extends RowAction
{
    public $name = '属性上报';

    public function handle(Model $model, Request $request)
    {
        $device_name = $this->row->devices->device_name;
        $box_name = $this->row->name;
        $rule = json_encode(['get'=>$box_name]);
        $res = (new DeviceServer())->sendMsg(intval($device_name),$rule);
        if($res['Success'] == true){
            return $this->response()->success('获取规则成功')->refresh();
        }
        return $this->response()->error('获取规则失败');

    }
}
