You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.0 KiB

  1. <?php
  2. namespace App\Model\v3;
  3. use App\Model\Model;
  4. class OrderGoods extends Model
  5. {
  6. protected $table = 'lanzu_order_goods';
  7. protected $casts = [
  8. 'spec' => 'array',
  9. 'tags' => 'array',
  10. ];
  11. protected $appends = [
  12. 'tags'
  13. ];
  14. protected $fillable = [
  15. 'order_id',
  16. 'goods_id',
  17. 'activity_type',
  18. 'number',
  19. 'status',
  20. 'price',
  21. 'original_price',
  22. 'vip_price',
  23. 'name',
  24. 'goods_unit',
  25. 'cover_img',
  26. 'spec',
  27. 'refund_time',
  28. 'created_at',
  29. 'updated_at',
  30. 'deleted_at',
  31. 'refuse_refund_note',
  32. 'refund_note',
  33. ];
  34. public function goods()
  35. {
  36. return $this->belongsTo(Goods::class, 'goods_id', 'id');
  37. }
  38. public function goodsActivity()
  39. {
  40. return $this->belongsTo(GoodsActivity::class, 'goods_id', 'id');
  41. }
  42. public function getTagsAttribute()
  43. {
  44. return Goods::query()->where(['id' => $this->attributes['goods_id']])->value('tags');
  45. }
  46. }