where('driver', $row['driver'])->find()) { return false; } } public function getCategoryAttr($value): string { return $value == '' ? 'unclassed' : $value; } public function setCategoryAttr($value) { return $value == 'unclassed' ? '' : $value; } /** * 获取Mimetype列表 * @return array */ public static function getMimetypeList() { $data = [ "image/*" => "图片", "audio/*" => "音频", "video/*" => "视频", "text/*" => "文档", "application/*" => "应用", "zip,rar,7z,tar" => "压缩包", ]; return $data; } /** * 获取定义的附件类别列表 * @return array */ public static function getCategoryList(): array { $data = config('site.attachmentcategory') ?? []; // 添加未归类选项 $data['unclassed'] = '未归类'; return $data; } /** * 返回上传文件的相关信息 */ public function getBaseData() { $data = [ 'url' => $this->path, 'fullurl' => cdnurl($this->path, true), 'category' => $this->category, 'filename' => $this->name, 'filesize' => $this->size, 'mimetype' => $this->mime, ]; return $data; } }