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.
44 lines
886 B
44 lines
886 B
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Customer;
|
|
|
|
class Balance extends SoftDeletesModel
|
|
{
|
|
protected $table = "balance";
|
|
public $appends = ["belongs_name"];
|
|
|
|
public function getBelongsNameAttribute()
|
|
{
|
|
$name = $this->belongs_type;
|
|
switch ($this->belongs_type) {
|
|
case Recharge::class:
|
|
$name = "充值";
|
|
break;
|
|
case Refund::class:
|
|
$name = "退款";
|
|
break;
|
|
case OrderItems::class:
|
|
$name = "订单扣款";
|
|
break;
|
|
}
|
|
return $name;
|
|
}
|
|
|
|
public function belongs()
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
|
|
public function customer()
|
|
{
|
|
return $this->belongsTo(Customer::class);
|
|
}
|
|
|
|
public function order()
|
|
{
|
|
return $this->hasOne(Orders::class, "id", "order_id");
|
|
}
|
|
}
|