12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace catchAdmin\system\model;
- use catchAdmin\system\model\search\AttachmentsSearch;
- use catcher\base\CatchModel;
- use think\file\UploadedFile;
- use think\Model;
- class Attachments extends CatchModel
- {
- use AttachmentsSearch;
- protected $name = 'attachments';
-
- protected $field = [
- 'id',
- 'path',
- 'url',
- 'mime_type',
- 'file_ext',
- 'file_size',
- 'filename',
- 'driver',
- 'created_at',
- 'updated_at',
- 'deleted_at',
- ];
- public function getList()
- {
- return $this->order('id', 'desc')
- ->catchSearch()
- ->catchOrder()
- ->paginate();
- }
-
- 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']
- ]);
- }
- }
|