CouponGood.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\common\model;
  13. use app\common\library\helper;
  14. /**
  15. * 优惠券商品模型
  16. * Class Coupon
  17. * @package app\common\model
  18. */
  19. class CouponGood extends BaseModel
  20. {
  21. // 定义表名
  22. protected $name = 'coupon_goods';
  23. // 定义主键
  24. protected $pk = 'id';
  25. const EXCEPT_YES = 1;
  26. public function image()
  27. {
  28. $model = "app\\common\\model\\UploadFile";
  29. return $this->belongsTo($model, 'image_id', 'file_id');
  30. }
  31. /**
  32. * 获取器:规格属性
  33. * @param $value
  34. * @return array
  35. */
  36. public function getGoodsPropsAttr($value)
  37. {
  38. return helper::jsonDecode($value);
  39. }
  40. /**
  41. * 设置器:规格属性
  42. * @param $value
  43. * @return string
  44. */
  45. public function setGoodsPropsAttr($value)
  46. {
  47. return !empty($value) ? helper::jsonEncode($value) : '';
  48. }
  49. /**
  50. * 获取记录
  51. * @param int $id
  52. * @param array $with
  53. * @return static
  54. */
  55. public static function detail(int $id, array $with = [])
  56. {
  57. return static::get($id, $with);
  58. }
  59. }