belongsTo(Order::class);
}
public function product()
{
return $this->belongsTo(Product::class);
}
public function scopePaid($query)
{
return $query->whereHas('order', function ($query) {
$query->where('payment_status', 1);
});
}
public function scopeRefunded($query)
{
return $query->where('is_refunded', Status::YES);
}
public function buyer()
{
return $this->belongsTo(User::class, 'user_id');
}
public function licenseBadge(): Attribute
{
return new Attribute(function () {
$html = '';
if ($this->license == Status::PERSONAL_LICENSE) {
$html = '' . trans('Personal') . '';
} else {
$html = '' . trans('Commercial') . '';
}
return $html;
});
}
public function refundedBadge(): Attribute
{
return new Attribute(function () {
$html = '';
if ($this->is_refunded == Status::YES) {
$html = '' . trans('Yes') . '';
} else {
$html = '' . trans('No') . '';
}
return $html;
});
}
}