You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

47 lines
1.1 KiB

  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class Attachment extends Model
  5. {
  6. // 开启自动写入时间戳字段
  7. protected $autoWriteTimestamp = 'int';
  8. // 定义时间戳字段名
  9. protected $createTime = 'createtime';
  10. protected $updateTime = 'updatetime';
  11. // 定义字段类型
  12. protected $type = [
  13. ];
  14. public function setUploadtimeAttr($value)
  15. {
  16. return is_numeric($value) ? $value : strtotime($value);
  17. }
  18. public static function getMimetypeList()
  19. {
  20. $data = [
  21. "image/*" => "图片",
  22. "audio/*" => "音频",
  23. "video/*" => "视频",
  24. "text/*" => "文档",
  25. "application/*" => "应用",
  26. "zip,rar,7z,tar" => "压缩包",
  27. ];
  28. return $data;
  29. }
  30. protected static function init()
  31. {
  32. // 如果已经上传该资源,则不再记录
  33. self::beforeInsert(function ($model) {
  34. if (self::where('url', '=', $model['url'])->find()) {
  35. return false;
  36. }
  37. });
  38. }
  39. }