feat: Reimplement order and invoice management with new service and repository layers, introduce compression middleware, and update database schema.

This commit is contained in:
pbao9
2026-03-12 09:30:29 +07:00
parent 7f6264c87f
commit 1e09ccf17b
87 changed files with 2348 additions and 2612 deletions
+33 -25
View File
@@ -10,50 +10,58 @@ class OrderItem extends Model
use HasFactory;
protected $table = 'order_items';
protected $guarded = [];
public $timestamps = false;
protected $casts = [
'addons_meta' => 'array',
];
// -------------------------------------------------------------------------
// Relationships
// -------------------------------------------------------------------------
public function order()
{
return $this->belongsTo(Order::class, 'order_id');
}
public function addons()
{
return $this->hasMany(OrderAddon::class, 'order_item_id');
}
public function getProductAttribute()
{
if ($this->product_id) {
return Product::find($this->product_id);
}
return null;
}
/**
* Relationship: OrderItem belongs to Product (new system)
*/
public function product()
{
return $this->belongsTo(Product::class, 'product_id');
}
/**
* Relationship: OrderItem has pricing info
*/
public function pricing()
{
return $this->belongsTo(ProductPricings::class, 'product_pricing_id');
}
public function os()
{
return $this->belongsTo(Os::class, 'os_id');
}
/** The provisioned service spawned from this order line. */
public function service()
{
return $this->hasOne(Service::class, 'order_item_id');
}
// -------------------------------------------------------------------------
// Helpers
// -------------------------------------------------------------------------
public function getBillingLabelAttribute(): string
{
return match ((int) $this->months) {
0 => 'One Time',
1 => 'Monthly',
3 => 'Quarterly',
6 => 'Semi-Annually',
12 => 'Annually',
24 => '2 Years',
36 => '3 Years',
default => $this->months . ' Months',
};
}
}