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.

60 lines
1.2 KiB

5 years ago
5 years ago
  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. 'name_unit'
  14. ];
  15. protected $fillable = [
  16. 'order_id',
  17. 'goods_id',
  18. 'activity_type',
  19. 'number',
  20. 'status',
  21. 'price',
  22. 'original_price',
  23. 'vip_price',
  24. 'name',
  25. 'goods_unit',
  26. 'cover_img',
  27. 'spec',
  28. 'refund_time',
  29. 'created_at',
  30. 'updated_at',
  31. 'deleted_at',
  32. 'refuse_refund_note',
  33. 'refund_note',
  34. ];
  35. public function goods()
  36. {
  37. return $this->belongsTo(Goods::class, 'goods_id', 'id');
  38. }
  39. public function goodsActivity()
  40. {
  41. return $this->belongsTo(GoodsActivity::class, 'goods_id', 'id');
  42. }
  43. public function getTagsAttribute()
  44. {
  45. return Goods::query()->where(['id' => $this->attributes['goods_id']])->value('tags');
  46. }
  47. public function getNameUnitAttribute()
  48. {
  49. return $this->attributes['name'] . ' ' . $this->attributes['goods_unit'];
  50. }
  51. }