feat: Add active pricing details to service list resource and eager load only active pricings in the service repository.

This commit is contained in:
pbao9
2026-02-11 11:52:43 +07:00
parent 8ecea7badc
commit 58a9aa685b
2 changed files with 7 additions and 1 deletions
@@ -32,6 +32,12 @@ class ServiceListResource extends JsonResource
'stock' => $this->stock,
'price' => $this->price,
'price_sale' => $this->price_sale,
'pricing' => $this->pricings->mapWithKeys(function ($pricing) {
return [$pricing->billing_cycle => $pricing->price];
}),
'pricing_sale' => $this->pricings->mapWithKeys(function ($pricing) {
return [$pricing->billing_cycle => $pricing->price_sale];
}),
'group' => $this->category->name,
'os' => $this->osVersions->groupBy('os_group_id')->map(function ($versions) {
$group = $versions->first()->osGroup;