海南旅游SAAS
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.

48 lines
916 B

  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. class Order extends BaseModel
  6. {
  7. use HasFactory, SoftDeletes;
  8. protected $guarded = ['created_at', 'updated_at']; //不可批量赋值的属性
  9. public function getCouponIdAttribute($value)
  10. {
  11. return explode(',', $value);
  12. }
  13. public function getStatusAttribute($value)
  14. {
  15. $this->append('status_text');
  16. return $value;
  17. }
  18. public function getStatusTextAttribute()
  19. {
  20. $status_text = [
  21. -1 => '已取消',
  22. 0 => '待付款',
  23. 1 => '已付定金',
  24. 2 => '已付款',
  25. 3 => '已付尾款',
  26. 6 => '退款中',
  27. 7 => '已退款',
  28. 16 => '已完成',
  29. ];
  30. return $status_text[$this->status] ?? '未知';
  31. }
  32. public function product()
  33. {
  34. return $this->belongsTo(Product::class);
  35. }
  36. public function coupon()
  37. {
  38. return $this->belongsTo(Coupon::class);
  39. }
  40. }