_init(); } protected function _init(){ } /** * 返回格式化json数据 * * @param int $code * @param string $msg * @param array $data * @return Response */ protected function json(int $code, string $msg = 'ok', array|object|null $data = []): Response { return json(['code' => $code, 'data' => $data, 'msg' => $msg]); } protected function success(string $msg = '成功', array|object|null $data = []): Response { return $this->json(0, $msg, $data); } protected function fail(string $msg = '失败', array|object|null $data = []): Response { return $this->json(1,$msg, $data); } protected function error(string $msg = '失败', array|object|null $data = []): Response { return $this->json(1,$msg, $data); } /** * @Apidoc\Title("上传") * @Apidoc\Method("POST") */ function upload(Request $request) { //多文件上传 $files = $request->file(); try { $result = Storage::adapter('public') ->path('upload/files') ->size(1024*1024*10) ->extYes(['image/jpeg','image/png']) ->uploads($files,0,1024*1024*100,false); return $this->success(__('successful'),$result); }catch (\Exception $e){ return $this->error($e->getMessage()); } } }