<?php


namespace App\Admin\Controllers;

use App\Model\DeviceInfo;
use Illuminate\Contracts\Support\Renderable;
class Qrcode implements  Renderable
{
    public function render($key = null)
    {
        $device = DeviceInfo::where(['id'=>$key])->first();
        if(empty($device)){
            return  '设备设置缺失！';
        }
        $url = env('APP_URL').'/test_op?id='.$device->device_name;
        $html = <<<Script
        <div id="qrcode"></div>
        <script type="text/javascript">
        var  qrcode;
          document.getElementById("qrcode").innerHTML=""
          qrcode = new QRCode(document.getElementById("qrcode"), '$url');
          qrcode.makeCode('$url');
        </script>
Script;
        return $html;

    }
}
