money::class, 'commission' => money::class];
protected $guarded = [];
public function scopeUid(Builder $query): Builder
{
return $query->whereInviterId(Auth::id());
}
public function invitee(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function inviter(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function order(): BelongsTo
{
return $this->belongsTo(Order::class);
}
protected function amountTag(): Attribute
{
return Attribute::make(
get: fn () => Helpers::getPriceTag($this->amount),
);
}
protected function commissionTag(): Attribute
{
return Attribute::make(
get: fn () => Helpers::getPriceTag($this->commission),
);
}
protected function statusLabel(): Attribute
{
return Attribute::make(
get: fn () => match ($this->status) {
1 => ''.trans('common.status.applying').'',
2 => ''.trans('common.status.withdrawn').'',
default => ''.trans('common.status.withdrawal_pending').'',
},
);
}
}