feat: Add IT Support catalog and related migrations, seeders, and email templates

- Created migration to add 'group_label' to 'product_type_fields' table.
- Implemented ItSupportCatalogSeeder to populate IT Support features and tiers.
- Added ProductCategorySeeder for initial product categories.
- Developed ProductMockupSeeder for mockup products in various categories.
- Introduced ProductTypeFieldSeeder to define fields for different product types.
- Created email templates for VPS service information and service renewal reminders.
This commit is contained in:
baodev0
2026-08-26 16:19:38 +07:00
parent 382b7c0ef8
commit c917e3bf5e
47 changed files with 2992 additions and 1759 deletions
@@ -72,6 +72,7 @@ class ProductController extends Controller
'ram' => 'nullable|numeric|min:0',
'disk' => 'nullable|numeric|min:0',
'bandwidth' => 'nullable|numeric|min:0',
'domain_count' => 'nullable|integer|min:0',
'billing_type' => 'nullable|string|in:recurring,onetime',
'currency' => 'nullable|string|max:10',
'price_monthly' => 'nullable|numeric|min:0',
@@ -81,6 +82,7 @@ class ProductController extends Controller
'price_biennially' => 'nullable|numeric|min:0',
'price_triennially' => 'nullable|numeric|min:0',
'price_onetime' => 'nullable|numeric|min:0',
'features' => 'nullable|array',
]);
$productType = $validated['product_type'] ?? null;
@@ -103,6 +105,8 @@ class ProductController extends Controller
'ram' => $validated['ram'] ?? null,
'disk' => $validated['disk'] ?? null,
'bandwidth' => $validated['bandwidth'] ?? null,
'domain_count' => $validated['domain_count'] ?? null,
'features' => $validated['features'] ?? null,
]);
$this->savePricings($product, $validated);
@@ -135,6 +139,7 @@ class ProductController extends Controller
'ram' => 'nullable|numeric|min:0',
'disk' => 'nullable|numeric|min:0',
'bandwidth' => 'nullable|numeric|min:0',
'domain_count' => 'nullable|integer|min:0',
'os_ids' => 'nullable|array',
'os_ids.*' => 'integer|exists:os,id',
'module_host_id' => 'nullable|integer|exists:module_host,id',
@@ -148,6 +153,7 @@ class ProductController extends Controller
'price_biennially' => 'nullable|numeric|min:0',
'price_triennially' => 'nullable|numeric|min:0',
'price_onetime' => 'nullable|numeric|min:0',
'features' => 'nullable|array',
]);
if (isset($validated['name']) && $validated['name'] !== $product->name) {
@@ -0,0 +1,71 @@
<?php
namespace App\Http\Controllers\Api\Admin\Product;
use App\Http\Controllers\Controller;
use App\Http\Requests\ProductTypeField\ProductTypeFieldRequest;
use App\Http\Resources\Api\Admin\ProductTypeFieldResource;
use App\Models\ProductTypeField;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ProductTypeFieldController extends Controller
{
public function index(Request $request): JsonResponse
{
$items = ProductTypeField::query()
->when($request->get('product_type'), fn ($q, $type) => $q->where('product_type', $type))
->orderBy('sort_order')
->orderBy('id')
->get();
return response()->json([
'error' => false,
'data' => ProductTypeFieldResource::collection($items),
]);
}
public function store(ProductTypeFieldRequest $request): JsonResponse
{
$field = ProductTypeField::create($request->validated());
return response()->json([
'error' => false,
'message' => 'Tạo field thành công.',
'data' => new ProductTypeFieldResource($field),
], 201);
}
public function update(ProductTypeFieldRequest $request, int $id): JsonResponse
{
$field = ProductTypeField::find($id);
if (!$field) {
return response()->json(['error' => true, 'message' => 'Không tìm thấy field.'], 404);
}
$field->update($request->validated());
return response()->json([
'error' => false,
'message' => 'Cập nhật field thành công.',
'data' => new ProductTypeFieldResource($field),
]);
}
public function destroy(int $id): JsonResponse
{
$field = ProductTypeField::find($id);
if (!$field) {
return response()->json(['error' => true, 'message' => 'Không tìm thấy field.'], 404);
}
$field->delete();
return response()->json([
'error' => false,
'message' => 'Xoá field thành công.',
]);
}
}