feat: Implement client-facing service management API with UUID for services and bulk actions for product services.

This commit is contained in:
pbao9
2026-03-13 15:17:23 +07:00
parent 5160ac967a
commit e0341363f6
16 changed files with 479 additions and 3 deletions
@@ -0,0 +1,54 @@
<?php
namespace App\Repositories\Api\ServiceClient;
use App\Models\Service;
use App\Repositories\Api\BaseApiRepository;
class ServiceClientRepository extends BaseApiRepository implements ServiceClientRepositoryInterface
{
public function getModel()
{
return Service::class;
}
/**
* Lấy danh sách sản phẩm đang hoạt động
*/
public function getActiveServices(int $limit = 10)
{
return $this->model
->with(['orderItem' => fn($q) => $q->with('product')])
->where('status', 'active')
->orderBy('started_at', 'asc')
->paginate($limit);
}
public function findActiveBySlug(string $slug)
{
return $this->model
->with(['osVersions.osGroup', 'category', 'pricings' => fn ($q) => $q->where('is_active', 1)])
->where('slug', $slug)
->where('is_active', 1)
->first();
}
public function getPricing(int $productId, string $billingCycle)
{
$pricing = $this->model->find($productId)
->pricings()
->where('billing_cycle', $billingCycle)
->where('is_active', 1)
->first();
return $pricing ? $pricing->price : null;
}
public function getDetailService(string $uuid)
{
return $this->model
->with(['orderItem.os.osGroup.host.datacenter.vCenter'])
->where('uuid', $uuid)
->first();
}
}