GoodsCoupon.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * Author: 芸众商城 www.yunzshop.com
  4. * Date: 2017/7/13
  5. * Time: 下午3:10
  6. */
  7. namespace app\common\models\goods;
  8. use app\common\models\BaseModel;
  9. class GoodsCoupon extends BaseModel
  10. {
  11. public $table = 'yz_goods_coupon';
  12. public $timestamps = false;
  13. protected $guarded = [''];
  14. protected $casts = [
  15. 'coupon' => 'json',
  16. 'share_coupon' => 'json',
  17. ];
  18. public $attributes = [
  19. 'goods_id' => 0,
  20. 'is_give' => 0,
  21. 'send_type' => 0,
  22. 'send_num' => 0,
  23. ];
  24. public function scopeOfGoodsId($query,$goodsId)
  25. {
  26. return $query->where('goods_id',$goodsId);
  27. }
  28. //todo 废弃使用==删除,使用 ofGoodsId() 方法
  29. /*public static function getGoodsCouponByGoodsId($goodsId)
  30. {
  31. return self::where('goods_id',$goodsId);
  32. }*/
  33. public function rules()
  34. {
  35. return [
  36. //'goods_id' => '',
  37. //'is_give' => '',
  38. //'coupon' => '',
  39. //'send_type' => '',
  40. 'send_num' => 'numeric|integer',
  41. ];
  42. }
  43. public function atributeNames()
  44. {
  45. return [
  46. //'goods_id' => '',
  47. //'is_give' => '',
  48. //'coupon' => '',
  49. //'send_type' => '',
  50. 'send_num' => '优惠券发送次数',
  51. ];
  52. }
  53. }