belongsTo('RiceCard', 'card_id'); } public function image() { $model = "app\\common\\model\\UploadFile"; return $this->belongsTo($model, 'image_id', 'file_id'); } /** * 获取器:规格属性 * @param $value * @return array */ public function getGoodsPropsAttr($value) { return helper::jsonDecode($value); } /** * 设置器:规格属性 * @param $value * @return string */ public function setGoodsPropsAttr($value) { return !empty($value) ? helper::jsonEncode($value) : ''; } /** * 获取记录 * @param int $id * @param array $with * @return static */ public static function detail(int $id, array $with = []) { return static::get($id, $with); } }