feat: Implement addon functionality with schema updates, seeder, and administrator UI adjustments, including new favicons and a migration snapshot.

This commit is contained in:
pbao9
2026-02-13 10:07:24 +07:00
parent 64c3182b00
commit b127fa7c66
13 changed files with 4441 additions and 525 deletions
+3841
View File
File diff suppressed because it is too large Load Diff
+3 -1
View File
@@ -12,6 +12,7 @@ class Addon extends Model
protected $table = 'product_addon';
protected $fillable = [
'type_id',
'code',
'name',
'price',
@@ -19,6 +20,7 @@ class Addon extends Model
'max',
'step',
'prefix',
'status'
'status',
'sort_order'
];
}
@@ -14,6 +14,7 @@ return new class extends Migration {
{
Schema::create('product_addon', function (Blueprint $table) {
$table->id();
$table->string('type_id', 50)->default('vps')->index();
$table->string('code', 50)->unique();
$table->string('name', 100);
$table->string('prefix', 50)->nullable();
@@ -24,6 +25,7 @@ return new class extends Migration {
$table->enum('input_type', ['number', 'slider', 'select'])
->default('number');
$table->boolean('status')->default(true);
$table->integer('sort_order')->default(0)->index();
$table->timestamps();
});
}
+6
View File
@@ -11,6 +11,7 @@ class AddonSeeder extends Seeder
{
$addons = [
[
'type_id' => 'vps',
'code' => 'cpu',
'name' => 'CPU',
'price' => 100000,
@@ -19,8 +20,10 @@ class AddonSeeder extends Seeder
'step' => 1,
'prefix' => 'vCore',
'status' => true,
'sort_order' => 0,
],
[
'type_id' => 'vps',
'code' => 'ram',
'name' => 'RAM',
'price' => 50000,
@@ -29,8 +32,10 @@ class AddonSeeder extends Seeder
'step' => 1,
'prefix' => 'GB',
'status' => true,
'sort_order' => 1,
],
[
'type_id' => 'vps',
'code' => 'disk',
'name' => 'SSD',
'price' => 4000,
@@ -39,6 +44,7 @@ class AddonSeeder extends Seeder
'step' => 10,
'prefix' => 'GB',
'status' => true,
'sort_order' => 2,
],
];
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 82 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 82 KiB

@@ -30,7 +30,7 @@
<!-- CSRF Token -->
<meta name="_token" content="{{ csrf_token() }}">
<link rel="shortcut icon" href="{{ asset('/favicon.ico') }}">
<link rel="shortcut icon" href="{{ asset('/images/favi.svg') }}">
<!-- plugin css -->
@foreach (config('assets.static.css') as $css)
@@ -51,7 +51,7 @@
<div class="page-wrapper">
@include('administrator.layout.partials.header')
<div class="page-content">
<div class="card mb-4 bg-white shadow-sm">
<div class="card mb-4 bg-white rounded-4 shadow-none">
<div class="card-body p-3">
@yield('breadcrumb')
@yield('tab')
@@ -43,11 +43,11 @@
@endsection
@section('content')
@if(auth()->guard('admins')->user()->can("manager module vcenter"))
<div class="card card-primary card-outline">
<div class="card rounded-4 shadow-none">
<div class="card-header d-flex justify-content-end gap-2">
@include("administrator.pages.block.ModuleVCenter")
</div>
<div class="card-body">
<div class="card-body p-0">
<x-datatable id="vcenterTable" ajax="{{ route('module.vcenter.datatable') }}" :columns="[
['key' => 'host', 'label' => 'Host'],
['key' => 'user', 'label' => 'User'],
@@ -39,7 +39,7 @@
@csrf
<div class="row">
<div class="col-md-8">
<div class="card card-primary card-outline">
<div class="card card-primary card-outline rounded-4 shadow-none">
<div class="card-header">
<h5 class="card-title m-0">Basic Information</h5>
</div>
@@ -63,7 +63,8 @@
@if(isset($categories))
@foreach($categories as $category)
<option value="{{ $category->id }}" {{ old('parent_id') == $category->id ? 'selected' : '' }}>
{{ $category->name }}</option>
{{ $category->name }}
</option>
@endforeach
@endif
</select>
@@ -73,7 +74,7 @@
</div>
<div class="col-md-4">
<div class="card card-secondary card-outline">
<div class="card card-secondary card-outline shadow-none rounded-4">
<div class="card-header">
<h5 class="card-title m-0">Classification</h5>
</div>
@@ -100,9 +101,10 @@
</div>
<x-fixed-action-bar>
<x-button-crm type="button" variant="secondary" size="sm" icon="arrow-left"
route="products.group.index">Cancel</x-button-crm>
<x-button-crm type="submit" variant="primary" size="sm" icon="plus-circle">Create Category</x-button-crm>
<x-button-crm type="button" variant="outline-info" size="sm" icon="arrow-left"
route="products.group.index">Back</x-button-crm>
<x-button-crm type="submit" variant="outline-primary" size="sm" icon="plus-circle">Create
Category</x-button-crm>
</x-fixed-action-bar>
</form>
@endsection
@@ -7,17 +7,17 @@
@section('breadcrumb')
@php
$breadcrumbItems = [
$breadcrumbItems = [
['label' => 'Product'],
['label' => 'Product Group'],
['label' => 'Product Group List', 'active' => true]
];
];
@endphp
<x-admin-breadcrumb :items="$breadcrumbItems" />
@endsection
@section('tab')
@php
$tabs = [
$tabs = [
[
'label' => 'Product',
'route' => 'products.index',
@@ -28,17 +28,17 @@ $tabs = [
'route' => 'products.group.index',
'icon' => 'server',
],
];
];
@endphp
<x-admin-tab :items="$tabs" />
@endsection
@section('content')
@if (auth()->guard('admins')->user()->can('manager product'))
<div class="card card-primary card-outline">
<div class="card-header d-flex justify-content-end gap-2">
<div class="card rounded-4 shadow-none">
<div class="card-header d-flex justify-content-end gap-2 rounded-top-4">
@include('administrator.pages.block.product.btn')
</div>
<div class="card-body">
<div class="card-body p-0">
<x-datatable id="productTable" ajax="{{ route('products.group.datatable') }}"
bulkDeleteUrl="{{ route('products.group.bulkDelete') }}" :columns="[
['key' => 'details_control', 'label' => '', 'orderable' => false, 'searchable' => false, 'className' => 'details-control text-center cursor-pointer'],
@@ -38,8 +38,8 @@
<div class="row align-items-start">
{{-- Left Column: Basic Info & Pricing --}}
<div class="col-md-8">
<div class="card card-primary card-outline">
<div class="card-header">
<div class="card card-primary card-outline rounded-4 shadow-none">
<div class="card-header rounded-top-4">
<h5 class="card-title m-0">Basic Information</h5>
</div>
<div class="card-body">
@@ -195,8 +195,8 @@
{{-- Right Column: Classification & Settings --}}
<div class="col-md-4 sticky-top top-10 z-0">
<div class="card card-secondary card-outline mb-3">
<div class="card-header">
<div class="card card-secondary card-outline mb-3 rounded-4 shadow-none">
<div class="card-header rounded-top-4">
<h5 class="card-title m-0">Classification</h5>
</div>
<div class="card-body">
@@ -305,8 +305,8 @@
</div>
</div>
<div class="card card-secondary card-outline">
<div class="card-header">
<div class="card card-secondary card-outline rounded-4 shadow-none">
<div class="card-header rounded-top-4">
<h5 class="card-title m-0">Inventory & Limits</h5>
</div>
<div class="card-body">
@@ -52,7 +52,7 @@
$variantClass = $variants[$variant ?? 'primary'] ?? $variants['primary'];
$sizeClass = $sizes[$size ?? 'default'] ?? '';
$classes = "btn d-flex align-items-center {$variantClass} {$sizeClass}";
$classes = "btn d-flex align-items-center rounded-4 border {$variantClass} {$sizeClass}";
@endphp
@if($tag === 'a')
<a href="{{ $href }}" {{ $attributes->merge(['class' => $classes]) }}>
+82 -37
View File
@@ -1,7 +1,7 @@
@props(['id', 'columns', 'ajax', 'bulkDeleteUrl' => null])
@php
$dtColumns = collect($columns)
$dtColumns = collect($columns)
->map(function ($c) {
return [
'data' => $c['key'],
@@ -22,8 +22,8 @@ $dtColumns = collect($columns)
<span class="fw-medium"><span id="{{ $id }}-selected-count">0</span> items selected</span>
</div>
<div class="vr bg-danger opacity-25"></div>
<x-button-c-r-m type="button" variant="danger" size="sm" icon="trash-2"
id="{{ $id }}-bulk-delete-opener-btn" class="shadow-sm">
<x-button-c-r-m type="button" variant="danger" size="sm" icon="trash-2" id="{{ $id }}-bulk-delete-opener-btn"
class="shadow-sm">
Delete Selected
</x-button-c-r-m>
</div>
@@ -58,14 +58,14 @@ $dtColumns = collect($columns)
</div>
</div>
@endif
<div class="data-table-wrapper rounded-3 border-light position-relative overflow-hidden border">
<div class="data-table-wrapper position-relative overflow-hidden shadow-none">
{{-- Loading Process Indicator --}}
<div class="loading-process" id="{{ $id }}-loading" style="display: none;">
<div class="loading-bar"></div>
<div class="loading-overlay"></div>
</div>
<table id="{{ $id }}" class="table-hover mb-0 table bg-white align-middle"
<table id="{{ $id }}" class="table-hover mb-0 table bg-white shadow-none align-middle"
style="width:100%; border-collapse: separate; border-spacing: 0;">
<thead class="bg-light">
<tr>
@@ -102,8 +102,7 @@ $dtColumns = collect($columns)
</span>
<input type="text"
class="form-control form-control-sm border-start-0 column-search border-light bg-white ps-0 shadow-none"
placeholder="Filter..." data-column="{{ $loop->index }}"
style="font-size: 0.8125rem;">
placeholder="Filter..." data-column="{{ $loop->index }}" style="font-size: 0.8125rem;">
</div>
@endif
</th>
@@ -117,7 +116,7 @@ $dtColumns = collect($columns)
</div>
@push('custom-scripts')
<script>
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
$.fn.DataTable.ext.pager.numbers_length = 7;
var table = $('#{{ $id }}').DataTable({
@@ -144,9 +143,9 @@ $dtColumns = collect($columns)
zeroRecords: '<div class="d-flex flex-column align-items-center justify-content-center py-5"><div class="text-secondary mb-3"><i data-lucide="inbox" width="28" height="28" stroke-width="1.5"></i></div><h6 class="text-secondary fw-medium">No matching records found</h6></div>',
emptyTable: '<div class="d-flex flex-column align-items-center justify-content-center py-5"><div class="text-secondary mb-3"><i data-lucide="inbox" width="28" height="28" stroke-width="1.5"></i></div><h6 class="text-secondary fw-medium">No data available</h6></div>'
},
dom: "<'row p-3'<'col-sm-12'tr>>" +
"<'row px-3 pb-3 pt-1 align-items-center'<'col-sm-12 col-md-5 text-muted small'i><'col-sm-12 col-md-7 d-flex align-items-center justify-content-end gap-2'lp>>",
initComplete: function() {
dom: "<'row p-0'<'col-sm-12'tr>>" +
"<'row px-3 pb-3 pt-3 align-items-center'<'col-sm-12 col-md-5 text-muted small'i><'col-sm-12 col-md-7 d-flex align-items-center justify-content-end gap-2'lp>>",
initComplete: function () {
// Initialize select2 with custom styling
$('.dataTables_length select').select2({
minimumResultsForSearch: Infinity,
@@ -157,14 +156,14 @@ $dtColumns = collect($columns)
// Debounced search for column inputs (ERP Standard: Reduce server load)
let searchTimeouts = {};
this.api().columns().every(function() {
this.api().columns().every(function () {
var that = this;
$('input', this.header()).on('keyup change clear', function() {
$('input', this.header()).on('keyup change clear', function () {
const colIdx = that.index();
const value = this.value;
clearTimeout(searchTimeouts[colIdx]);
searchTimeouts[colIdx] = setTimeout(function() {
searchTimeouts[colIdx] = setTimeout(function () {
if (that.search() !== value) {
that.search(value).draw();
}
@@ -172,7 +171,7 @@ $dtColumns = collect($columns)
});
});
},
drawCallback: function() {
drawCallback: function () {
// Re-initialize Select2 on draw (if lost)
if ($('.dataTables_length select').data('select2')) {
$('.dataTables_length select').select2('destroy');
@@ -183,7 +182,7 @@ $dtColumns = collect($columns)
});
// Re-initialize icons with slight delay to ensuring DOM is ready
setTimeout(function() {
setTimeout(function () {
if (window.lucide) {
lucide.createIcons();
}
@@ -192,7 +191,7 @@ $dtColumns = collect($columns)
});
// ERP Standard: Double click row to edit
$('#{{ $id }} tbody').on('dblclick', 'tr', function() {
$('#{{ $id }} tbody').on('dblclick', 'tr', function () {
// Try to find an edit link in the row
const editLink = $(this).find('a.btn-outline-primary, a[href*="edit"]').first();
if (editLink.length && editLink.attr('href')) {
@@ -201,7 +200,7 @@ $dtColumns = collect($columns)
});
// Custom Loading Process Logic
table.on('processing.dt', function(e, settings, processing) {
table.on('processing.dt', function (e, settings, processing) {
const loadingEl = $('#{{ $id }}-loading');
if (processing) {
loadingEl.fadeIn(100);
@@ -211,19 +210,19 @@ $dtColumns = collect($columns)
});
// Prevent sorting when clicking on the input
$('#{{ $id }} thead tr:eq(1) th').on('click', function(e) {
$('#{{ $id }} thead tr:eq(1) th').on('click', function (e) {
e.stopPropagation();
});
// External trigger for column search (redundant but kept for manual binding if needed)
$('#{{ $id }} .column-search').on('keyup change', function() {
$('#{{ $id }} .column-search').on('keyup change', function () {
var columnIndex = $(this).data('column');
table.column(columnIndex).search(this.value).draw();
});
});
@if ($bulkDeleteUrl)
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
const tableId = '#{{ $id }}';
const bulkActions = $('#{{ $id }}-bulk-actions');
const deleteBtn = $('#{{ $id }}-bulk-delete-btn');
@@ -232,13 +231,13 @@ $dtColumns = collect($columns)
let selectedIds = [];
// Handle Master Checkbox
$(document).on('change', '#dt-master-checkbox', function() {
$(document).on('change', '#dt-master-checkbox', function () {
const isChecked = $(this).is(':checked');
$('.dt-checkbox').prop('checked', isChecked).trigger('change');
});
// Handle Individual Checkbox
$(document).on('change', '.dt-checkbox', function() {
$(document).on('change', '.dt-checkbox', function () {
const id = $(this).val();
if ($(this).is(':checked')) {
if (!selectedIds.includes(id)) selectedIds.push(id);
@@ -273,7 +272,7 @@ $dtColumns = collect($columns)
});
// Reset selection on table draw
$('#{{ $id }}').on('draw.dt', function() {
$('#{{ $id }}').on('draw.dt', function () {
selectedIds = [];
bulkActions.hide();
masterCheckbox.prop('checked', false);
@@ -288,7 +287,7 @@ $dtColumns = collect($columns)
const countDisplay = $('#{{ $id }}-bulk-delete-count-display');
let bsModal = null;
openerBtn.on('click', function() {
openerBtn.on('click', function () {
if (selectedIds.length === 0) return;
countDisplay.text(selectedIds.length);
@@ -299,7 +298,7 @@ $dtColumns = collect($columns)
});
// Handle Confirm Delete
confirmBtn.on('click', function() {
confirmBtn.on('click', function () {
$.ajax({
url: '{{ $bulkDeleteUrl }}',
type: 'DELETE',
@@ -307,10 +306,10 @@ $dtColumns = collect($columns)
ids: selectedIds,
_token: '{{ csrf_token() }}'
},
beforeSend: function() {
beforeSend: function () {
confirmBtn.prop('disabled', true).text('Deleting...');
},
success: function(response) {
success: function (response) {
if (bsModal) bsModal.hide();
$('#{{ $id }}').DataTable().ajax.reload();
selectedIds = [];
@@ -325,7 +324,7 @@ $dtColumns = collect($columns)
// Re-render icons after reload
if (window.lucide) lucide.createIcons();
},
error: function(xhr) {
error: function (xhr) {
const message = xhr.responseJSON?.message ||
'Something went wrong.';
if (typeof FuiToast !== 'undefined') {
@@ -335,7 +334,7 @@ $dtColumns = collect($columns)
}
if (bsModal) bsModal.hide();
},
complete: function() {
complete: function () {
confirmBtn.prop('disabled', false).text('Delete');
}
});
@@ -363,7 +362,14 @@ $dtColumns = collect($columns)
vertical-align: middle;
position: sticky;
top: 0;
z-index: 3; {{-- Lowered from 10 --}}
z-index: 3;
{
{
-- Lowered from 10 --
}
}
background-color: #f8f9fa;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
@@ -374,14 +380,27 @@ $dtColumns = collect($columns)
position: sticky;
right: 0;
background: #fff;
z-index: 2; {{-- Lowered from 5 --}}
z-index: 2;
{
{
-- Lowered from 5 --
}
}
border-left: 1px solid #f1f5f9;
box-shadow: -2px 0 5px rgba(0, 0, 0, 0.02);
}
.table thead th:last-child {
background: #f8f9fa;
z-index: 4; {{-- Lowered from 11 --}}
z-index: 4;
{
{
-- Lowered from 11 --
}
}
}
/* Sticky Checkbox Column */
@@ -390,14 +409,27 @@ $dtColumns = collect($columns)
position: sticky;
left: 0;
background: #fff;
z-index: 2; {{-- Lowered from 5 --}}
z-index: 2;
{
{
-- Lowered from 5 --
}
}
border-right: 1px solid #f1f5f9;
box-shadow: 2px 0 5px rgba(0, 0, 0, 0.02);
}
.table thead th:first-child {
background: #f8f9fa;
z-index: 4; {{-- Lowered from 11 --}}
z-index: 4;
{
{
-- Lowered from 11 --
}
}
}
.table tbody tr:hover td {
@@ -497,7 +529,14 @@ $dtColumns = collect($columns)
left: 0;
right: 0;
bottom: 0;
z-index: 5; {{-- Lowered from 1000 --}}
z-index: 5;
{
{
-- Lowered from 1000 --
}
}
pointer-events: none;
}
@@ -509,7 +548,13 @@ $dtColumns = collect($columns)
width: 100%;
background: #f1f5f9;
overflow: hidden;
z-index: 6; {{-- Lowered from 1001 --}}
z-index: 6;
{
{
-- Lowered from 1001 --
}
}
}
.loading-bar::after {