getKey(); } /** * Return a key value array, containing any custom claims to be added to the JWT. * * @return array */ public function getJWTCustomClaims() { return []; } /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'username', 'password', 'openid', 'balance', 'mobile' ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'verified_at' => 'datetime', ]; public function patients() { return $this->hasMany(Patient::class, "customer_id"); } public function balances() { return $this->hasMany(Balance::class, "customer_id"); } public function recharges() { return $this->hasMany(Recharge::class, "customer_id")->whereNotNull("paid_at"); } public function getOnlineRefundableRecharge($amount) { //todo:根据交易状态是否可以退款、以及多次退款金额是否足够进行更精准筛选 //but:出问题的几率微乎其微可以忽略 $recharge = Recharge::where("customer_id", $this->id) ->whereNotNull("paid_at") ->whereIn("payment", ["weixin", "alipay"]) ->doesntHave("refunds") ->orderBy("id", "desc") ->first(); return $recharge; } }