<?php

namespace App\Http\Controllers\API;

use App\Http\Controllers\Controller;
use App\Services\Admin\YeWu\HealthCheckupService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;

class UpLoadController extends Controller
{
    public function UpFile(){
        $file=request('file');
        $WangEditorImageFile=request('WangEditorImageFile');
        if(isset($file)){
            if ($file->isValid()) {
//            $s=app()->make(HealthCheckupService::class);
//            $save=$s->SaveFile(['file'=>$file]);
                $date = date("Ymd");
                $save = $file->store('public/'.$date);
                return \Yz::Return(true,'上传成功',Storage::url($save));
            }else{
                return \Yz::echoError1("上传失败");
            }
        }
        if(isset($WangEditorImageFile)){
            $result = array();
            if ($WangEditorImageFile->isValid()) {
                $date = date("Ymd");
                $save = $WangEditorImageFile->store('public/'.$date);


                $result['status'] = true;
                $result['msg'] ='上传成功';
                $result['data'] = ["url"=>env('APP_URL').Storage::url($save)];
                $result['errno'] = 0;

            }else{
                $result['status'] = false;
                $result['msg'] ='失败';
                $result['message'] ='上传失败';
                $result['data'] = [];
                $result['errno'] = 1;
            }
            return $result;
        }


    }
}
