<?php

namespace App\Http\Controllers\Common;

use App\Http\Controllers\Controller;
use App\Services\App\KfService;
use Illuminate\Http\Request;

/**
 * Class QrcodeMediasController
 * @package App\Http\Controllers\Common
 */
class QrcodeMediasController extends Controller
{
    /**
     * 获取原始资源
     * @param  Request  $request
     * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
     */
    public function getQrcode(Request $request)
    {
        $key = $request->get("key", null);
        $kfs = new KfService();
        if ($boolUrl = $kfs->getOriginMedia($key)) {
            return response(array(
                'code' => 200,
                'message' => 'success',
                'data' => [
                    'url' => $boolUrl
                ]
            ));
        } else {
            return response(array(
                'code' => 404,
                'message' => 'no media'
            ));
        }
    }
}
