// +---------------------------------------------------------------------- declare (strict_types=1); namespace app\api\model; use app\common\model\ActiveMain as ActiveMainModel; use think\model\relation\HasMany; /** * 活动模型类 * Class User * @package app\common\model */ class ActiveMain extends ActiveMainModel { //追加字段 protected $append = [ //首页图片 'index_icon', //活动主题图 'theme_pic' ]; public function getList($param) { return $this->with('col') ->where('status', '=', 1) ->where('id', $param['active_id']) ->find(); } public function getIndexIconAttr($value, $data) { $file = $this->with('indexImage')->find(); return $file['indexImage']['preview_url']; } public function getThemePicAttr($value, $data) { $file = $this->with('themeImage')->find(); return $file['themeImage']['preview_url']; } }