belongsTo('UploadGroup', 'group_id'); } /** * 获取图片完整路径 * @param $value * @param $data * @return string */ public function getFilePathAttr($value, $data) { if ($data['storage'] === 'local') { return self::$base_url . 'uploads/' . $data['file_name']; } return $data['file_url'] . '/' . $data['file_name']; } /** * 文件详情 * @param $file_id * @return null|static * @throws \think\exception\DbException */ public static function detail($file_id) { return self::get($file_id); } /** * 根据文件名查询文件id * @param $fileName * @return mixed */ public static function getFildIdByName($fileName) { return (new static)->where(['file_name' => $fileName])->value('file_id'); } /** * 查询文件id * @param $fileId * @return mixed */ public static function getFileName($fileId) { return (new static)->where(['file_id' => $fileId])->value('file_name'); } /** * 添加新记录 * @param $data * @return false|int */ public function add($data) { $data['wxapp_id'] = self::$wxapp_id; return $this->save($data); } }