From c06e7b869482b2fdcdaef03e9e185fc483dc1b17 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Mon, 1 Jun 2020 21:28:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=99=84=E4=BB=B6=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- catch/system/model/Attachments.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/catch/system/model/Attachments.php b/catch/system/model/Attachments.php index 9a340c0..8120c74 100644 --- a/catch/system/model/Attachments.php +++ b/catch/system/model/Attachments.php @@ -2,6 +2,8 @@ namespace catchAdmin\system\model; use catcher\base\CatchModel; +use think\file\UploadedFile; +use think\Model; class Attachments extends CatchModel { @@ -42,4 +44,25 @@ class Attachments extends CatchModel { return $query->where('driver', $value); } + + /** + * + * + * @time 2020年06月01日 + * @param $data ['driver' => '', 'path' => '', 'url' => ], + * @param UploadedFile $file + * @return Attachments|Model + */ + public static function store($data, UploadedFile $file) + { + return parent::create([ + 'file_size' => $file->getSize(), + 'mime_type' => $file->getMime(), + 'file_ext' => $file->getOriginalExtension(), + 'filename' => $file->getOriginalName(), + 'driver' => $data['driver'], + 'url' => $data['url'], + 'path' => $data['path'] + ]); + } }