<?php

namespace App\Admin\Actions\Device;

use App\Server\DeviceServer;
use Encore\Admin\Actions\Action;
use Illuminate\Http\Request;

class Reflash extends Action
{
    protected $selector = '.reflash';

    public function handle(Request $request)
    {
        // $request ...

       $res = (new DeviceServer())->refreshList();

       if ($res !== true)
           return $this->response()->error($res)->refresh();
       return $this->response()->success('设备更新成功')->refresh();


    }

    public function html()
    {
        return <<<HTML
        <a class="btn btn-sm btn-danger reflash" style="margin-right: 10px;"><i class="fa fa-refresh"></i>&nbsp;刷新设备信息</a>
HTML;
    }
}