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
48 lines
916 B
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Order extends BaseModel
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
protected $guarded = ['created_at', 'updated_at']; //不可批量赋值的属性
|
|
|
|
public function getCouponIdAttribute($value)
|
|
{
|
|
return explode(',', $value);
|
|
}
|
|
|
|
public function getStatusAttribute($value)
|
|
{
|
|
$this->append('status_text');
|
|
return $value;
|
|
}
|
|
|
|
public function getStatusTextAttribute()
|
|
{
|
|
$status_text = [
|
|
-1 => '已取消',
|
|
0 => '待付款',
|
|
1 => '已付定金',
|
|
2 => '已付款',
|
|
3 => '已付尾款',
|
|
6 => '退款中',
|
|
7 => '已退款',
|
|
16 => '已完成',
|
|
];
|
|
return $status_text[$this->status] ?? '未知';
|
|
}
|
|
|
|
public function product()
|
|
{
|
|
return $this->belongsTo(Product::class);
|
|
}
|
|
|
|
public function coupon()
|
|
{
|
|
return $this->belongsTo(Coupon::class);
|
|
}
|
|
}
|