1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace app\common\model;
- use think\Model;
- class Attachment extends Model
- {
-
- protected $autoWriteTimestamp = 'int';
-
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
-
- protected $type = [
- ];
- public function setUploadtimeAttr($value)
- {
- return is_numeric($value) ? $value : strtotime($value);
- }
- public static function getMimetypeList()
- {
- $data = [
- "image/*" => "图片",
- "audio/*" => "音频",
- "video/*" => "视频",
- "text/*" => "文档",
- "application/*" => "应用",
- "zip,rar,7z,tar" => "压缩包",
- ];
- return $data;
- }
- protected static function init()
- {
-
- self::beforeInsert(function ($model) {
- if (self::where('url', '=', $model['url'])->where('storage', $model['storage'])->find()) {
- return false;
- }
- });
- }
- }
|