'int', 'name' => 'varchar', 'savename' => 'varchar', 'size' => 'int', 'ext' => 'varchar', 'path' => 'varchar', 'fullpath' => 'varchar', 'md5' => 'varchar', 'create_at' => 'datetime', 'type' => 'int', 'uid' => 'int', ]; protected $append = [ 'url', 'type_txt', 'preview' ]; // 处理大图路径 public function getUrlAttr($value,$data) { return WEBURL.$data['path']; } // 预览图 public function getPreviewAttr($value,$data) { $url = WEBURL.$data['path']; $prev = $url.'.prev.'.$data['ext']; $prevPath = public_path().$data['path'].'.prev.'.$data['ext']; return file_exists($prevPath)?$prev:$url; } // 类型列表 static public function typeList() { return ['other'=>'文件','images'=>'图片','audio'=>'音频','video'=>'视频']; } // 上传文件类型文字 public function getTypeTxtAttr($value,$data) { $value = $value ? $value : (isset($data['type']) ? $data['type'] : ''); $typeList = self::typeList(); return isset($typeList[$value]) ? $typeList[$value] : ''; } }