更新附件模型

This commit is contained in:
JaguarJack 2020-06-01 21:28:04 +08:00
parent fe6ea82014
commit c06e7b8694

View File

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