From 9cae94b807ef9de1c4c119958985fdcf31700a35 Mon Sep 17 00:00:00 2001 From: baodev0 Date: Tue, 14 Jul 2026 10:14:50 +0700 Subject: [PATCH] Add ServiceController for managing customer services; implement index, show, and detachCustomer methods --- .../Api/Admin/Service/ServiceController.php | 50 ++++ .../customer/password-reset-admin.blade.php | 249 +++++++++++++----- routes/api.php | 8 + 3 files changed, 245 insertions(+), 62 deletions(-) create mode 100644 app/Http/Controllers/Api/Admin/Service/ServiceController.php diff --git a/app/Http/Controllers/Api/Admin/Service/ServiceController.php b/app/Http/Controllers/Api/Admin/Service/ServiceController.php new file mode 100644 index 0000000..ed3c555 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Service/ServiceController.php @@ -0,0 +1,50 @@ +per_page ?? 15), 100); + + $query = Service::with(['customer:id,uuid,fullname,email', 'product:id,uuid,name', 'invoice:id,invoice_number', 'vmware:id,name,module_ip_address']) + ->when($request->filter, fn($q, $v) => $q->where('server_name', 'like', "%{$v}%")) + ->when($request->status, fn($q, $v) => $q->where('status', $v)) + ->when($request->customer_id, fn($q, $v) => $q->where('customer_id', $v)); + + $paginator = $query->latest()->paginate($perPage); + + return response()->json([ + 'error' => false, + 'data' => [ + 'items' => $paginator->items(), + 'total' => $paginator->total(), + 'per_page' => $paginator->perPage(), + 'current_page' => $paginator->currentPage(), + 'last_page' => $paginator->lastPage(), + ], + ]); + } + + public function show(int $id): JsonResponse + { + $service = Service::with(['customer', 'product', 'orderItem', 'invoice', 'vmware', 'addons']) + ->findOrFail($id); + + return response()->json(['error' => false, 'data' => $service]); + } + + public function detachCustomer(int $id): JsonResponse + { + $service = Service::findOrFail($id); + $service->update(['customer_id' => null]); + + return response()->json(['error' => false, 'message' => 'Đã gỡ khách hàng khỏi dịch vụ.']); + } +} diff --git a/resources/views/emails/customer/password-reset-admin.blade.php b/resources/views/emails/customer/password-reset-admin.blade.php index d054de7..6b69aec 100644 --- a/resources/views/emails/customer/password-reset-admin.blade.php +++ b/resources/views/emails/customer/password-reset-admin.blade.php @@ -1,63 +1,188 @@ - - - - - - Cập nhật mật khẩu — {{ $appName }} - - - -
-
-
-
🔐
-

Mật khẩu của bạn đã được cập nhật

-
+@php + $appName = $appName ?? config('app.name', 'Thế Giới Số'); + $fullName = $fullName ?? 'Quý khách'; + $email = $email ?? ''; + $password = $password ?? ''; + $loginUrl = $loginUrl ?? rtrim((string) env('FRONTEND_URL', config('app.url')), '/') . '/dang-nhap'; + $supportEmail = $supportEmail ?? 'support@tgs.com.vn'; + $supportPhone = $supportPhone ?? '1900. 6119'; +@endphp -
-

- Xin chào {{ $fullName }}, -

-

- Quản trị viên của {{ $appName }} vừa cấp lại mật khẩu mới cho tài khoản của bạn. - Vui lòng sử dụng thông tin bên dưới để đăng nhập và đổi lại mật khẩu của bạn ngay sau đó. -

- -
-
Tài khoản: {{ $email }}
-
Mật khẩu mới: {{ $password }}
-
- - - -

- Nếu bạn không yêu cầu thao tác này, vui lòng liên hệ ngay với chúng tôi qua - {{ $supportEmail }}. -

-
- - -
-
- - + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + +
+
🔐
+

+ Mật khẩu của bạn đã được cập nhật +

+
+ Quản trị viên vừa cấp lại mật khẩu mới cho tài khoản của bạn +
+
+ + + + + + +
+
 
+
Xin chào {{ $fullName }},
+
 
+
+ Quản trị viên của {{ $appName }} vừa cấp lại mật khẩu mới cho tài khoản của bạn. + Vui lòng sử dụng thông tin bên dưới để đăng nhập và đổi lại mật khẩu của bạn ngay sau đó. +
+
 
+ + + + + + +
+
Tài khoản: {{ $email }}
+
Mật khẩu mới: {{ $password }}
+
+
 
+ +
 
+
+ Nếu bạn không yêu cầu thao tác này, vui lòng liên hệ ngay với chúng tôi qua {{ $supportEmail }}. +
+
 
+
+ Email này được gửi tự động. Vui lòng không trả lời email này. +
+
 
+
+
+
+ + + + + + + + + + + + + + + + + + +
+ + + + + + +
 
+
 
+ + + + + + + + + + + + + + +
  + Premium HOSTING +   + Cloud SERVER +   + EMAIL DOANH NGHIỆP +   + Thiết Kế WEBSITE +  
+
 
+ + + + + + +
 
+
+
+ + + + + + + + + + + + +
 
+

+ CÔNG TY CỔ PHẦN GIẢI PHÁP CÔNG NGHỆ THẾ GIỚI SỐ
+ Địa chỉ: 128/38 Tân Hương, Phường Phú Thọ Hòa, Thành Phố Hồ Chí Minh
+ Tel: (028) 7309. 7379 - Tổng đài: {{ $supportPhone }}
+ Email: {{ $supportEmail }}
+ + www.TGS.com.vn & + www.thegioiso.CLOUD & + www.thegioiSERVER.com & + www.CloudEmail.vn + +

+

+ + + + 🥇Thế Giới Số🥇- Premium HOSTING • CLOUD • SERVER & WEBSITE | 15+ năm Phụng Sự 🚀 + + + +

+
 
+
+
diff --git a/routes/api.php b/routes/api.php index 65ba3f2..93911d3 100644 --- a/routes/api.php +++ b/routes/api.php @@ -19,6 +19,7 @@ use App\Http\Controllers\Api\Admin\Addon\AddonController; use App\Http\Controllers\Api\Admin\WebDesign\WebDesignQuoteController; use App\Http\Controllers\Api\Admin\Product\ProductCategoryController; use App\Http\Controllers\Api\Admin\Product\ProductController; +use App\Http\Controllers\Api\Admin\Service\ServiceController; use App\Http\Controllers\Api\Admin\VPS\VPSController; use App\Http\Controllers\Api\Admin\VCenter\VCenterController; use App\Http\Controllers\Api\Admin\DnsManager\ServerController as DnsServerController; @@ -148,6 +149,13 @@ Route::prefix('v1') Route::delete('{uuid}/force', 'forceDelete')->middleware('perm:customer.destroy'); }); + // Services (module: customer) + Route::prefix('services')->controller(ServiceController::class)->group(function () { + Route::get('/', 'index')->middleware('perm:customer.view'); + Route::get('{id}', 'show')->middleware('perm:customer.view'); + Route::patch('{id}/detach-customer', 'detachCustomer')->middleware('perm:customer.edit'); + }); + // Products (module: product-service) Route::prefix('products') ->controller(ProductController::class)