0, 'points_deduction_amount' => 0, 'status' => OfflineOrderStatus::Pending, ]; protected $casts = [ 'payment_time' => 'datetime', 'status' => OfflineOrderStatus::class, 'payment_method' => PayWay::class, 'revoked_at' => 'datetime', ]; protected $fillable = [ 'user_id', 'store_id', 'staff_id', 'sn', 'products_total_amount', 'discount_reduction_amount', 'points_deduction_amount', 'payment_amount', 'payment_sn', 'payment_method', 'payment_time', 'out_trade_no', 'status', 'revoked_at', 'orderable_type', 'orderable_id', ]; public function store() { return $this->belongsTo(Store::class); } public function staff() { return $this->belongsTo(User::class, 'staff_id'); } public function staffInfo() { return $this->belongsTo(UserInfo::class, 'staff_id', 'user_id'); } public function user() { return $this->belongsTo(User::class); } public function userInfo() { return $this->belongsTo(UserInfo::class, 'user_id', 'user_id'); } public function payLogs() { return $this->morphMany(PayLog::class, 'payable'); } public function isPending(): bool { return $this->status === OfflineOrderStatus::Pending; } public function isPaid(): bool { return $this->status === OfflineOrderStatus::Paid; } public function isRevoked(): bool { return $this->status === OfflineOrderStatus::Revoked; } }