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.
66 lines
1.4 KiB
66 lines
1.4 KiB
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Customer;
|
|
use App\Manager;
|
|
|
|
class Recharge extends SoftDeletesModel
|
|
{
|
|
protected $table = "recharge";
|
|
|
|
public function getPaymentLabelAttribute()
|
|
{
|
|
$payment_label = $this->payment;
|
|
switch ($this->payment) {
|
|
case "weixin":
|
|
$payment_label = "微信";
|
|
break;
|
|
case "alipay":
|
|
$payment_label = "支付宝";
|
|
break;
|
|
case "cash":
|
|
$payment_label = "现金";
|
|
break;
|
|
case "pos":
|
|
$payment_label = "POS机";
|
|
break;
|
|
}
|
|
return $payment_label;
|
|
}
|
|
|
|
public function customer()
|
|
{
|
|
return $this->belongsTo(Customer::class);
|
|
}
|
|
|
|
public function manager()
|
|
{
|
|
return $this->belongsTo(Manager::class);
|
|
}
|
|
|
|
public function order()
|
|
{
|
|
return $this->belongsTo(Orders::class);
|
|
}
|
|
|
|
public function patient() {
|
|
return $this->hasOneThrough(Patient::class, Orders::class,"id","id","order_id","patient_id");
|
|
}
|
|
|
|
public function refunds() {
|
|
return $this->hasMany(Refund::class,"recharge_id");
|
|
}
|
|
|
|
public function getSerial()
|
|
{
|
|
if ($this->serial) {
|
|
return $this;
|
|
}
|
|
$serial = date("YmdHis", strtotime($this->created_at)) . sprintf("%06d", $this->id);
|
|
$this->update(["serial" => $serial]);
|
|
return $this;
|
|
}
|
|
|
|
}
|