- Implemented client access token verification middleware to secure API endpoints. - Updated ServiceController to fetch active hosting services for authenticated users. - Refactored OrderController to ensure order retrieval is customer-specific. - Improved error logging in VmController for unexpected vCenter responses. - Disabled VNPay auto-deposit in TransactionController, switching to manual deposit flow. - Enhanced ServiceClientDetailResource to include Plesk credentials for hosting accounts. - Adjusted VpsServiceResource to dynamically set page type based on product type. - Added logging for PowerShellService to capture errors in RDP port changes. - Provisioning job now resolves service plans and logs relevant information for hosting accounts. - Updated database migrations to add necessary fields for service plans and DNS servers. - Refactored Service and ServicePlan models to establish relationships with hosting accounts and DNS servers.
74 lines
2.1 KiB
PHP
74 lines
2.1 KiB
PHP
<?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 toàn bộ dịch vụ của customer (mọi trạng thái)
|
|
*/
|
|
public function getActiveServices(int $customerId, ?string $productType = null, int $limit = 10)
|
|
{
|
|
$query = $this->model
|
|
->with([
|
|
'product',
|
|
'addons',
|
|
'invoice.order',
|
|
'orderItem' => fn($q) => $q->with(['product', 'os.osGroup', 'order']),
|
|
])
|
|
->where('customer_id', $customerId)
|
|
->orderByRaw("FIELD(status, 'active', 'pending', 'suspended', 'expired', 'cancelled', 'terminated')")
|
|
->orderBy('started_at', 'desc');
|
|
|
|
if ($productType) {
|
|
$query->where('type', $productType);
|
|
}
|
|
|
|
return $query->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, int $customerId)
|
|
{
|
|
return $this->model
|
|
->with([
|
|
'addons',
|
|
'orderItem.os.osGroup',
|
|
'orderItem.product',
|
|
'orderItem.order',
|
|
'vmware.ipAddress',
|
|
'hostingAccount.server',
|
|
])
|
|
->where('uuid', $uuid)
|
|
->where('customer_id', $customerId)
|
|
->first();
|
|
}
|
|
}
|