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.
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use App\Customer;
|
|
|
|
|
use App\Manager;
|
|
|
|
|
|
|
|
|
|
class Recharge extends SoftDeletesModel
|
|
|
|
|
{
|
|
|
|
|
protected $table = "recharge";
|
|
|
|
|
protected $appends = ["payment_name"];
|
|
|
|
|
public $payment_methods = [
|
|
|
|
|
"cash" => "现金",
|
|
|
|
|
"weixin" => "微信",
|
|
|
|
|
"alipay" => "支付宝",
|
|
|
|
|
"pos" => "POS机"
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public function getPaymentNameAttribute()
|
|
|
|
|
{
|
|
|
|
|
$payment_name = $this->payment;
|
|
|
|
|
if (isset($this->payment_methods[$payment_name])) {
|
|
|
|
|
$payment_name = $this->payment_methods[$payment_name];
|
|
|
|
|
}
|
|
|
|
|
return $payment_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|