12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace app\common\model\card;
- use app\common\library\helper;
- use app\common\model\BaseModel;
- /**
- * 米卡商品模型
- * @package app\common\model
- */
- class RiceCardGoods extends BaseModel
- {
- // 是否除外
- const EXCEPT_YES = 1; // 除外商品
- const EXCEPT_NO = 0; // 可兑换商品
- protected $name = 'rice_card_goods';
- /**
- * 关联 米卡表
- */
- public function riceCard()
- {
- return $this->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);
- }
-
- }
|