Files
portal-api/routes/client.php
T
baodev0 fccb0c353a feat: Add DNS management resources and importer
- Implemented DomainCollection, DomainDetailResource, DomainNSCollection, DomainNSResource, and DomainResource for handling DNS domain and record data.
- Created VpsServiceCollection and VpsServiceResource for VPS service management.
- Added DnsManagerNS and DnsManagerUser models to represent DNS records and user associations.
- Developed AdminZoneDnsSqlImporter for importing DNS data from SQL dumps, including customer and DNS domain records.
- Added migration scripts to update the customers table with new fields and sync foreign key references for DNS tables.
- Created a migration preview document outlining the mapping and schema changes for the admin zone DNS import.
2026-05-26 13:54:33 +07:00

257 lines
13 KiB
PHP

<?php
use App\Http\Controllers\Api\Setting\SettingController;
use App\Http\Controllers\Api\Client\ClientController;
use App\Http\Controllers\Api\Client\Service\DomainController as ClientDomainController;
use App\Http\Controllers\Api\Client\Service\ServiceController as ClientServiceController;
use App\Http\Controllers\Api\Service\OrderController;
use App\Http\Controllers\Api\Service\ProductCategoryController;
use App\Http\Controllers\Api\Service\ServiceController;
use App\Http\Controllers\Api\Service\SnapshotController;
use App\Http\Controllers\Api\Service\VmController;
use App\Http\Controllers\Api\Service\VmRebuildController;
use App\Http\Controllers\Api\Client\BankController as ClientBankController;
use App\Http\Controllers\Api\Client\Docs\PostCategoryController as ClientPostCategoryController;
use App\Http\Controllers\Api\Client\Docs\PostController as ClientPostController;
use App\Http\Controllers\Api\Client\Ticket\TicketController as ClientTicketController;
use App\Http\Controllers\Api\NotificationController;
use App\Http\Controllers\Api\Transaction\ManualDepositController;
use App\Http\Controllers\Api\Transaction\TransactionController;
use Illuminate\Support\Facades\Route;
Route::prefix('v1')
->as('api.')
->group(function () {
// Auth
Route::prefix('client')
->as('client.')
->group(function () {
Route::controller(ClientController::class)->group(function () {
Route::post('login', 'login')->name('login');
Route::post('register', 'register')->name('register');
Route::post('refresh', 'refresh')->name('refresh');
Route::group(['middleware' => ['api.auth']], function () {
Route::get('me', 'me')->name('me');
Route::post('logout', 'logout')->name('logout');
Route::put('update', 'update')->name('update');
});
});
Route::middleware(['api.auth'])
->controller(OrderController::class)
->group(function () {
Route::get('orders', 'getClientOrders')->name('orders.list');
Route::get('orders/{id}', 'getClientOrderDetail')->name('orders.detail');
Route::post('orders/{id}/retry', 'retryOrderProvisioning')->name('orders.retry');
Route::get('invoices', 'getClientInvoices')->name('invoices.list');
Route::get('invoices/{id}', 'getClientInvoiceDetail')->name('invoices.detail');
Route::get('invoices/order/{orderNum}', 'getClientInvoiceDetailByOrderNum')->name(
'invoices.detailByOrderNum',
);
Route::get('dich-vu', 'getClientServices')->name('services.list');
Route::patch('dich-vu/{id}/auto-renew', 'updateClientServiceAutoRenew')->name(
'services.autoRenew.update',
);
Route::post('dich-vu/{id}/renew', 'renewService')->name('services.renew');
});
Route::middleware(['api.auth'])
->prefix('client-service/domains')
->controller(ClientDomainController::class)
->as('client-service.domains.')
->group(function () {
Route::get('/', 'index')->name('list');
Route::get('{domainId}', 'show')->name('detail');
Route::get('{domainId}/records', 'show')->name('records');
Route::post('{domainId}/records', 'storeRecord')->name('records.store');
Route::put('{domainId}/records/{recordId}', 'updateRecord')->name('records.update');
Route::delete('{domainId}/records/{recordId}', 'destroyRecord')->name('records.destroy');
});
Route::middleware(['api.auth'])
->prefix('client-service')
->controller(ClientServiceController::class)
->as('client-service.')
->group(function () {
Route::get('vps', 'indexVps')->name('vps.list');
Route::get('hosting', 'indexHosting')->name('hosting.list');
Route::get('web-design', 'indexWebDesign')->name('web-design.list');
Route::get('{uuid}', 'getDetail')->name('detail');
Route::get('{uuid}/console-ticket', 'getConsoleTicket')->name('console-ticket');
Route::get('{uuid}/available-os', 'getAvailableOs')->name('available-os');
Route::post('{uuid}/rebuild', 'rebuild')->name('rebuild');
});
Route::middleware(['api.auth'])
->get('get-ticket-console', [ClientServiceController::class, 'getTicketByOrderNum'])
->name('console-ticket');
Route::middleware(['api.auth'])
->prefix('service')
->controller(ServiceController::class)
->as('service.')
->group(function () {
Route::get('/', 'getService')->name('list');
Route::get('{uuid}', 'getDetailServiceCustomer')->name('detail');
});
Route::middleware(['api.auth'])
->controller(TransactionController::class)
->group(function () {
Route::get('payment-history', 'getClientPaymentHistory')->name('payment-history.list');
});
Route::middleware(['api.auth'])
->prefix('notifications')
->controller(NotificationController::class)
->group(function () {
Route::get('/', fn () => app(NotificationController::class)->index(request(), 'client'));
Route::patch('{id}/read', fn ($id) => app(NotificationController::class)->markRead(request(), 'client', (int) $id));
Route::patch('read-all', fn () => app(NotificationController::class)->markAllRead(request(), 'client'));
});
Route::middleware(['api.auth'])
->prefix('tickets')
->controller(ClientTicketController::class)
->as('tickets.')
->group(function () {
Route::get('/', 'index')->name('index');
Route::post('/', 'store')->name('store');
Route::get('{ticket_num}', 'show')->name('show');
Route::post('{ticket_num}/reply', 'reply')->middleware('throttle:10,1')->name('reply');
Route::patch('{ticket_num}/close', 'close')->name('close');
});
});
// Services (Products) - Public & Protected Routes
Route::prefix('services')
->as('services.')
->group(function () {
Route::controller(ServiceController::class)->group(function () {
Route::get('get-list', 'getService')->name('getList');
Route::get('{product:slug}', 'getDetailService')->name('detail');
});
});
Route::middleware(['api.auth'])
->prefix('orders')
->as('orders.')
->group(function () {
Route::controller(OrderController::class)->group(function () {
Route::get('/', 'getList')->name('list');
Route::get('check-server-name', 'checkServerName')->name('check-server-name');
Route::post('/', 'storeOrder')->name('store');
Route::post('{id}/pay', 'payOrder')->name('pay');
});
});
Route::prefix('setting')
->as('setting.')
->group(function () {
Route::controller(SettingController::class)->group(function () {
Route::get('/', 'getSetting')->name('get');
});
});
// Public bank list for deposit form
Route::get('banks', [ClientBankController::class, 'index'])->name('banks.list');
Route::prefix('post-categories')
->controller(ClientPostCategoryController::class)
->as('client.docs.categories.')
->group(function () {
Route::get('/', 'index')->name('index');
});
Route::prefix('posts')
->controller(ClientPostController::class)
->as('client.docs.posts.')
->group(function () {
Route::get('/', 'index')->name('index');
Route::get('featured', 'featured')->name('featured');
Route::get('{slug}', 'show')->name('show');
});
// Product Categories - Public Routes (no auth required)
Route::prefix('group')
->as('product-categories.')
->group(function () {
Route::controller(ProductCategoryController::class)->group(function () {
Route::get('get-list', 'getCategories')->name('getList');
Route::get('{product_categories:slug}', 'getDetailCategory')->name('detail');
Route::get('{parentSlug}/{childSlug}', 'getChildCategoryWithParent')->name('childWithParent');
});
});
// Addons - Get available addons for a product
Route::prefix('products')
->as('products.')
->group(function () {
Route::get('{productId}/addons', [ServiceController::class, 'getProductAddons'])->name('addons');
});
Route::middleware(['api.auth'])
->prefix('transaction')
->as('transaction.')
->group(function () {
Route::controller(TransactionController::class)->group(function () {
Route::get('get-list', 'getTransactions')->name('getList');
Route::post('pay', 'handle')->name('pay');
Route::get('verify', 'verifyPayment')->name('verify');
Route::get('detail-by-code', 'getByPublicCode')->name('detailByCode');
});
Route::get('manual-deposit/pending', [ManualDepositController::class, 'pending'])->name('manualDeposit.pending');
Route::post('manual-deposit/prepare', [ManualDepositController::class, 'prepare'])->name('manualDeposit.prepare');
Route::post('manual-deposit/confirm', [ManualDepositController::class, 'confirm'])->name('manualDeposit.confirm');
Route::delete('manual-deposit/{uuid}/cancel', [ManualDepositController::class, 'cancel'])->name('manualDeposit.cancel');
Route::post('manual-deposit/upload-proof', [ManualDepositController::class, 'uploadProof'])->name('manualDeposit.uploadProof');
});
});
Route::get('v1/payment/vnpay/return', [TransactionController::class, 'returnCallback']);
Route::prefix('v1/system')
->middleware(['api.auth'])
->group(function () {
// VM power & network operations
Route::controller(VmController::class)->group(function () {
Route::get('vm-power-state', 'powerState')->name('vm.power-state');
Route::post('vm-power-on', 'powerOn')->name('vm.power-on');
Route::post('vm-power-off', 'powerOff')->name('vm.power-off');
Route::post('vm-change-ip', 'changeIp')->name('vm.change-ip');
Route::post('vm-change-port', 'changePort')->name('vm.change-port');
Route::post('vm-change-password', 'changePassword')->name('vm.change-password');
Route::get('get-ticket-console', 'consoleTicket')->name('vm.console-ticket');
Route::post('vm-restart', 'restart')->name('vm.restart');
});
// VM Snapshot operations
Route::controller(SnapshotController::class)->group(function () {
Route::get('vm-snapshots', 'index')->name('vm.snapshots');
Route::post('vm-create-snapshot', 'store')->name('vm.create-snapshot');
Route::post('vm-revert-snapshot', 'revert')->name('vm.revert-snapshot');
Route::post('vm-delete-snapshot', 'destroy')->name('vm.delete-snapshot');
});
// VM Rebuild & Addon operations
Route::controller(VmRebuildController::class)->group(function () {
Route::get('vm-rebuild-options', 'options')->name('vm.rebuild-options');
Route::post('vm-rebuild', 'rebuild')->name('vm.rebuild');
Route::get('vm-addon-options', 'addonOptions')->name('vm.addon-options');
Route::post('vm-upgrade-addons', 'upgradeAddons')->name('vm.upgrade-addons');
});
});
Route::any('{any}', function () {
return response()->json(
[
'error' => true,
'status' => 404,
'message' => 'API Route not found',
],
404,
);
})->where('any', '^v1/.*');