<?php

namespace App\Http\Controllers\Api\mini;

use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class UploadController extends BaseController
{
    protected $model;

    public function __construct()
    {

    }

    public function upload(Request $request)
    {
        if($request->hasFile('file')) {
            $item = $request->file('file');
            $fileName = uniqid() . '.' . $item->extension();
            $date = date("Ymd");
            $res = $item->storeAs('upload/images' . '/' . $date, $fileName);
            $path = url($res);
            return $this->success(['data' => ['path' => $path]]);
        }
        return $this->error(['msg' => '上传失败']);
    }
}
