refactor: Replace specific Hosting and VPS models and repositories with a generic Service repository and associated customer API endpoints.
This commit is contained in:
@@ -17,6 +17,7 @@ use App\Repositories\Module\Domain\DomainRepositoryInterface;
|
||||
use App\Repositories\Module\Hosting\HostingRepositoryInterface as ModuleHostingRepositoryInterface;
|
||||
use App\Repositories\Module\Vmware\VmwareRepositoryInterface;
|
||||
use App\Repositories\Order\OrderRepositoryInterface;
|
||||
use App\Repositories\Service\ServiceRepositoryInterface;
|
||||
use App\Repositories\Transaction\TransactionRepositoryInterface;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -35,6 +36,7 @@ class CustomerController extends Controller
|
||||
private readonly OrderRepositoryInterface $orderRepository,
|
||||
private readonly TransactionRepositoryInterface $transactionRepository,
|
||||
private readonly DomainRepositoryInterface $moduleDomainRepository,
|
||||
private readonly ServiceRepositoryInterface $serviceRepository,
|
||||
) {}
|
||||
|
||||
public function index(Request $request): JsonResponse
|
||||
@@ -473,4 +475,39 @@ class CustomerController extends Controller
|
||||
'data' => $domains
|
||||
]);
|
||||
}
|
||||
|
||||
public function getServices(string $uuid, Request $request): JsonResponse
|
||||
{
|
||||
$services = $this->serviceRepository->filter(
|
||||
['customer_uuid' => $uuid],
|
||||
['product', 'orderItem', 'invoice']
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'data' => $services
|
||||
]);
|
||||
}
|
||||
|
||||
public function getOrders(string $uuid, Request $request): JsonResponse
|
||||
{
|
||||
$customer = $this->customerRepository->findBy('uuid', $uuid);
|
||||
|
||||
if (!$customer) {
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => "Can't find customer by UUID #" . $uuid
|
||||
], 404);
|
||||
}
|
||||
|
||||
$orders = $this->orderRepository->filter(
|
||||
['client' => $customer->id],
|
||||
['customer', 'payment', 'invoice']
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'data' => $orders
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user