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'] + ]); + } }