| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\SoftDeletes;
- class PaymentDirectRecharge extends BaseModel
- {
- use SoftDeletes;
- protected $table = 'payment_direct_recharges';
- protected $guarded = [];
- protected $hidden = ['deleted_at'];
- protected $casts = [
- 'amount' => 'decimal:2',
- 'recharge_channel_group_ids' => 'array',
- 'status' => 'integer',
- ];
- protected $appends = ['fee_rate', 'actual_amount'];
- public function rechargeChannel()
- {
- return $this->belongsTo(RechargeChannel::class, 'recharge_channel_id');
- }
- public function getFeeRateAttribute($value = null): string
- {
- return $this->rechargeChannel
- ? bcmul((string)$this->rechargeChannel->rate, '100', 4)
- : '0.0000';
- }
- public function getActualAmountAttribute(): string
- {
- $rate = $this->rechargeChannel ? (string)$this->rechargeChannel->rate : '0';
- return bcsub((string)$this->amount, bcmul((string)$this->amount, $rate, 6), 2);
- }
- }
|