feat: Implement comprehensive product management, including categories, pricing, and integration into the order system.
This commit is contained in:
+2
-2
@@ -21,8 +21,8 @@
|
||||
<td>{{ $child->name }}</td>
|
||||
<td>{{ $child->slug }}</td>
|
||||
<td>
|
||||
<x-admin-badge :variant="$child->is_active ? Status::ACTIVE->value : Status::DEACTIVE->value">
|
||||
{{ $child->is_active ? Status::ACTIVE->label() : Status::DEACTIVE->label() }}
|
||||
<x-admin-badge :variant="$child->is_active ? Status::ACTIVE->value : Status::INACTIVE->value">
|
||||
{{ $child->is_active ? Status::ACTIVE->label() : Status::INACTIVE->label() }}
|
||||
</x-admin-badge>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@@ -213,10 +213,7 @@
|
||||
<select class="form-control select2" name="product_categories_id" id="product_categories_id">
|
||||
<option value="">-- Select Group --</option>
|
||||
@foreach ($group as $item)
|
||||
<option value="{{ $item->id }}"
|
||||
{{ old('product_categories_id') == $item->id ? 'selected' : '' }}>
|
||||
{{ $item->name }}
|
||||
</option>
|
||||
@include('administrator.pages.product.partials.category_options', ['item' => $item, 'level' => 0, 'selected' => old('product_categories_id')])
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -7,357 +7,358 @@
|
||||
|
||||
@section('breadcrumb')
|
||||
@php
|
||||
$breadcrumbItems = [
|
||||
['label' => 'Product'],
|
||||
['label' => 'Product / Services', 'url' => route('products.index')],
|
||||
['label' => 'Edit Product', 'active' => true],
|
||||
];
|
||||
$breadcrumbItems = [
|
||||
['label' => 'Product'],
|
||||
['label' => 'Product / Services', 'url' => route('products.index')],
|
||||
['label' => 'Edit Product', 'active' => true],
|
||||
];
|
||||
@endphp
|
||||
<x-admin-breadcrumb :items="$breadcrumbItems" />
|
||||
@endsection
|
||||
@section('content')
|
||||
<form action="{{ route('products.update', $product->id) }}" method="post">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<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">
|
||||
<h5 class="card-title m-0">Edit Product</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
{{-- Basic Information --}}
|
||||
<div class="mb-4">
|
||||
<h5 class="text-primary border-bottom mb-3 pb-2">Basic Information</h5>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="name">Product Name <span class="text-danger">*</span></label>
|
||||
<input type="text" id="name" name="name"
|
||||
value="{{ old('name', $product->name) }}"
|
||||
class="form-control" required placeholder="Enter product name" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label for="short_description">Short Description</label>
|
||||
<textarea name="short_description" id="short_description" rows="2" class="form-control"
|
||||
placeholder="Brief summary">{{ old('short_description', $product->short_description) }}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label for="description">Full Description</label>
|
||||
<textarea name="description" id="description" rows="4" class="form-control"
|
||||
placeholder="Detailed description">{{ old('description', $product->description) }}</textarea>
|
||||
</div>
|
||||
<form action="{{ route('products.update', $product->id) }}" method="post">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<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">
|
||||
<h5 class="card-title m-0">Edit Product</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
{{-- Pricing & Billing --}}
|
||||
<div class="mb-4">
|
||||
<h5 class="text-primary border-bottom mb-3 pb-2">Pricing & Billing</h5>
|
||||
{{-- Global Settings --}}
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="currency">Currency</label>
|
||||
<select name="currency" id="currency" class="form-control select2">
|
||||
<option value="USD"
|
||||
{{ old('currency', $product->currency ?? 'USD') == 'USD' ? 'selected' : '' }}>
|
||||
USD</option>
|
||||
<option value="VND"
|
||||
{{ old('currency', $product->currency ?? 'VND') == 'VND' ? 'selected' : '' }}>
|
||||
VND</option>
|
||||
</select>
|
||||
{{-- Basic Information --}}
|
||||
<div class="mb-4">
|
||||
<h5 class="text-primary border-bottom mb-3 pb-2">Basic Information</h5>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="name">Product Name <span class="text-danger">*</span></label>
|
||||
<input type="text" id="name" name="name"
|
||||
value="{{ old('name', $product->name) }}"
|
||||
class="form-control" required placeholder="Enter product name" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="setup_fee">Setup Fee</label>
|
||||
<input type="number" step="0.01" id="setup_fee" name="setup_fee"
|
||||
value="{{ old('setup_fee', $product->setup_fee ?? 0) }}" class="form-control">
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label for="short_description">Short Description</label>
|
||||
<textarea name="short_description" id="short_description" rows="2" class="form-control"
|
||||
placeholder="Brief summary">{{ old('short_description', $product->short_description) }}</textarea>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="trial_days">Trial Days</label>
|
||||
<input type="number" id="trial_days" name="trial_days"
|
||||
value="{{ old('trial_days', $product->trial_days ?? 0) }}" class="form-control">
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label for="description">Full Description</label>
|
||||
<textarea name="description" id="description" rows="4" class="form-control"
|
||||
placeholder="Detailed description">{{ old('description', $product->description) }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
{{-- Billing Cycles Table --}}
|
||||
<label class="fw-bold mb-2">Billing Cycles</label>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" style="width: 50px;">#</th>
|
||||
<th scope="col">Billing Cycle</th>
|
||||
<th scope="col">Price</th>
|
||||
<th scope="col">Sale Price</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (\App\Enums\Product\ProductBillingCycle::cases() as $cycle)
|
||||
@php
|
||||
$pricing = $product->pricings
|
||||
->where('billing_cycle', $cycle->value)
|
||||
->first();
|
||||
@endphp
|
||||
|
||||
{{-- Pricing & Billing --}}
|
||||
<div class="mb-4">
|
||||
<h5 class="text-primary border-bottom mb-3 pb-2">Pricing & Billing</h5>
|
||||
{{-- Global Settings --}}
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="currency">Currency</label>
|
||||
<select name="currency" id="currency" class="form-control select2">
|
||||
<option value="USD"
|
||||
{{ old('currency', $product->currency ?? 'USD') == 'USD' ? 'selected' : '' }}>
|
||||
USD</option>
|
||||
<option value="VND"
|
||||
{{ old('currency', $product->currency ?? 'VND') == 'VND' ? 'selected' : '' }}>
|
||||
VND</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="setup_fee">Setup Fee</label>
|
||||
<input type="number" step="0.01" id="setup_fee" name="setup_fee"
|
||||
value="{{ old('setup_fee', $product->setup_fee ?? 0) }}" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="trial_days">Trial Days</label>
|
||||
<input type="number" id="trial_days" name="trial_days"
|
||||
value="{{ old('trial_days', $product->trial_days ?? 0) }}" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{-- Billing Cycles Table --}}
|
||||
<label class="fw-bold mb-2">Billing Cycles</label>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="row" class="text-center align-middle">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox"
|
||||
id="cycle_{{ $cycle->value }}"
|
||||
name="pricing[{{ $cycle->value }}][enabled]" value="1"
|
||||
{{ old("pricing.{$cycle->value}.enabled", $pricing ? 1 : 0) ? 'checked' : '' }}>
|
||||
<label class="form-check-label"
|
||||
for="cycle_{{ $cycle->value }}"></label>
|
||||
</div>
|
||||
</th>
|
||||
<td class="align-middle">
|
||||
{{ $cycle->label() }}
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-text">$</span>
|
||||
<input type="number" step="0.01" class="form-control"
|
||||
name="pricing[{{ $cycle->value }}][price]" placeholder="0.00"
|
||||
value="{{ old("pricing.{$cycle->value}.price", $pricing->price ?? '') }}">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-text">$</span>
|
||||
<input type="number" step="0.01" class="form-control"
|
||||
name="pricing[{{ $cycle->value }}][price_sale]"
|
||||
placeholder="0.00"
|
||||
value="{{ old("pricing.{$cycle->value}.price_sale", $pricing->price_sale ?? '') }}">
|
||||
</div>
|
||||
</td>
|
||||
<th scope="col" style="width: 50px;">#</th>
|
||||
<th scope="col">Billing Cycle</th>
|
||||
<th scope="col">Price</th>
|
||||
<th scope="col">Sale Price</th>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (\App\Enums\Product\ProductBillingCycle::cases() as $cycle)
|
||||
@php
|
||||
$pricing = $product->pricings
|
||||
->where('billing_cycle', $cycle->value)
|
||||
->first();
|
||||
@endphp
|
||||
<tr>
|
||||
<th scope="row" class="text-center align-middle">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox"
|
||||
id="cycle_{{ $cycle->value }}"
|
||||
name="pricing[{{ $cycle->value }}][enabled]" value="1"
|
||||
{{ old("pricing.{$cycle->value}.enabled", $pricing ? 1 : 0) ? 'checked' : '' }}>
|
||||
<label class="form-check-label"
|
||||
for="cycle_{{ $cycle->value }}"></label>
|
||||
</div>
|
||||
</th>
|
||||
<td class="align-middle">
|
||||
{{ $cycle->label() }}
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-text">$</span>
|
||||
<input type="number" step="0.01" class="form-control"
|
||||
name="pricing[{{ $cycle->value }}][price]" placeholder="0.00"
|
||||
value="{{ old("pricing.{$cycle->value}.price", $pricing->price ?? '') }}">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-text">$</span>
|
||||
<input type="number" step="0.01" class="form-control"
|
||||
name="pricing[{{ $cycle->value }}][price_sale]"
|
||||
placeholder="0.00"
|
||||
value="{{ old("pricing.{$cycle->value}.price_sale", $pricing->price_sale ?? '') }}">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{{-- Hardware Specs (VPS/Dedicated) --}}
|
||||
<div class="mb-4">
|
||||
<h5 class="text-info border-bottom mb-3 pb-2">Hardware Specifications</h5>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="cpu">CPU</label>
|
||||
<input type="text" name="cpu" id="cpu" class="form-control"
|
||||
value="{{ old('cpu', $product->cpu) }}" placeholder="e.g. 2 Core" />
|
||||
{{-- Hardware Specs (VPS/Dedicated) --}}
|
||||
<div class="mb-4">
|
||||
<h5 class="text-info border-bottom mb-3 pb-2">Hardware Specifications</h5>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="cpu">CPU</label>
|
||||
<input type="text" name="cpu" id="cpu" class="form-control"
|
||||
value="{{ old('cpu', $product->cpu) }}" placeholder="e.g. 2 Core" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="ram">RAM</label>
|
||||
<input type="text" name="ram" id="ram" class="form-control"
|
||||
value="{{ old('ram', $product->ram) }}" placeholder="e.g. 4 GB" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="disk">Disk/Storage</label>
|
||||
<input type="text" name="disk" id="disk" class="form-control"
|
||||
value="{{ old('disk', $product->disk) }}" placeholder="e.g. 50 GB NVMe" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="ram">RAM</label>
|
||||
<input type="text" name="ram" id="ram" class="form-control"
|
||||
value="{{ old('ram', $product->ram) }}" placeholder="e.g. 4 GB" />
|
||||
<div class="row mt-3">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="bandwidth">Bandwidth</label>
|
||||
<input type="text" name="bandwidth" id="bandwidth" class="form-control"
|
||||
value="{{ old('bandwidth', $product->bandwidth) }}" placeholder="e.g. Unlimited" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="disk">Disk/Storage</label>
|
||||
<input type="text" name="disk" id="disk" class="form-control"
|
||||
value="{{ old('disk', $product->disk) }}" placeholder="e.g. 50 GB NVMe" />
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="gpu">GPU</label>
|
||||
<input type="text" name="gpu" id="gpu" class="form-control"
|
||||
value="{{ old('gpu', $product->gpu) }}" placeholder="Optional">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-3">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="bandwidth">Bandwidth</label>
|
||||
<input type="text" name="bandwidth" id="bandwidth" class="form-control"
|
||||
value="{{ old('bandwidth', $product->bandwidth) }}" placeholder="e.g. Unlimited" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="gpu">GPU</label>
|
||||
<input type="text" name="gpu" id="gpu" class="form-control"
|
||||
value="{{ old('gpu', $product->gpu) }}" placeholder="Optional">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- 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">
|
||||
<h5 class="card-title m-0">Classification</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{{-- Product Category --}}
|
||||
<div class="form-group mb-3">
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<label for="product_categories_id">Group</label>
|
||||
<a href="{{ route('products.group.index') }}"
|
||||
class="text-primary text-decoration-underline">
|
||||
<i data-lucide="plus" class="w-12px h-12px"></i>
|
||||
Thêm Group
|
||||
</a>
|
||||
{{-- 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">
|
||||
<h5 class="card-title m-0">Classification</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{{-- Product Category --}}
|
||||
<div class="form-group mb-3">
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<label for="product_categories_id">Group</label>
|
||||
<a href="{{ route('products.group.index') }}"
|
||||
class="text-primary text-decoration-underline">
|
||||
<i data-lucide="plus" class="w-12px h-12px"></i>
|
||||
Thêm Group
|
||||
</a>
|
||||
</div>
|
||||
<select class="form-control select2" name="product_categories_id" id="product_categories_id">
|
||||
<option value="">-- Select Group --</option>
|
||||
@foreach ($group as $item)
|
||||
@include('administrator.pages.product.partials.category_options', ['item' => $item, 'level' => 0, 'selected' => old('product_categories_id', $product->product_categories_id)])
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<select class="form-control select2" name="product_categories_id" id="product_categories_id">
|
||||
<option value="">-- Select Group --</option>
|
||||
@foreach ($group as $item)
|
||||
<option value="{{ $item->id }}"
|
||||
{{ old('product_categories_id', $product->product_categories_id) == $item->id ? 'selected' : '' }}>
|
||||
{{ $item->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{{-- Operating System (for VPS) --}}
|
||||
<div class="form-group mb-3" id="os-section">
|
||||
<label for="os_ids" class="mb-2">Operating System</label>
|
||||
@php
|
||||
$selectedOsIds = old('os_ids', $product->osVersions->pluck('id')->toArray());
|
||||
@endphp
|
||||
<select class="form-control select2" name="os_ids[]" id="os_ids" multiple
|
||||
data-placeholder="-- Select OS versions --">
|
||||
@foreach ($osVersions as $osVersion)
|
||||
<option value="{{ $osVersion->id }}"
|
||||
{{ in_array($osVersion->id, $selectedOsIds) ? 'selected' : '' }}>
|
||||
{{ $osVersion->osGroup->name ?? 'Unknown' }} - {{ $osVersion->version }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<small class="text-muted">Select multiple OS versions supported by this product</small>
|
||||
</div>
|
||||
|
||||
{{-- Control Panels (for Hosting) --}}
|
||||
<div class="form-group mb-3" id="control-panel-section" style="display: none;">
|
||||
<label for="control_panel_ids" class="mb-2">Control Panels</label>
|
||||
@php
|
||||
$selectedPanelIds = old('control_panel_ids', $product->controlPanels->pluck('id')->toArray());
|
||||
$panelPriceModifiers = old('control_panel_price_modifiers',
|
||||
$product->controlPanels->pluck('pivot.price_modifier', 'id')->toArray());
|
||||
$defaultPanel = old('control_panel_default',
|
||||
$product->controlPanels->where('pivot.is_default', true)->first()?->id);
|
||||
@endphp
|
||||
<select class="form-control select2" name="control_panel_ids[]" id="control_panel_ids" multiple data-placeholder="-- Select Control Panels --">
|
||||
@foreach ($controlPanels as $panel)
|
||||
<option value="{{ $panel->id }}" {{ in_array($panel->id, $selectedPanelIds) ? 'selected' : '' }}>
|
||||
{{ $panel->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<small class="text-muted">Select control panels available for this hosting product</small>
|
||||
|
||||
{{-- Price modifiers for each panel --}}
|
||||
<div id="panel-price-modifiers" class="mt-3">
|
||||
@foreach ($controlPanels as $panel)
|
||||
<div class="panel-price-row mb-2" id="panel-price-{{ $panel->id }}"
|
||||
style="display: {{ in_array($panel->id, $selectedPanelIds) ? 'block' : 'none' }};">
|
||||
<label class="form-label">{{ $panel->name }} - Phụ phí (VNĐ)</label>
|
||||
<div class="input-group">
|
||||
<input type="number"
|
||||
class="form-control"
|
||||
name="control_panel_price_modifiers[{{ $panel->id }}]"
|
||||
placeholder="0"
|
||||
min="0"
|
||||
step="1000"
|
||||
value="{{ $panelPriceModifiers[$panel->id] ?? 0 }}">
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<input type="radio"
|
||||
name="control_panel_default"
|
||||
value="{{ $panel->id }}"
|
||||
{{ $defaultPanel == $panel->id ? 'checked' : '' }}>
|
||||
<span class="ms-1">Mặc định</span>
|
||||
{{-- Operating System (for VPS) --}}
|
||||
<div class="form-group mb-3" id="os-section">
|
||||
<label for="os_ids" class="mb-2">Operating System</label>
|
||||
@php
|
||||
$selectedOsIds = old('os_ids', $product->osVersions->pluck('id')->toArray());
|
||||
@endphp
|
||||
<select class="form-control select2" name="os_ids[]" id="os_ids" multiple
|
||||
data-placeholder="-- Select OS versions --">
|
||||
@foreach ($osVersions as $osVersion)
|
||||
<option value="{{ $osVersion->id }}"
|
||||
{{ in_array($osVersion->id, $selectedOsIds) ? 'selected' : '' }}>
|
||||
{{ $osVersion->osGroup->name ?? 'Unknown' }} - {{ $osVersion->version }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<small class="text-muted">Select multiple OS versions supported by this product</small>
|
||||
</div>
|
||||
|
||||
{{-- Control Panels (for Hosting) --}}
|
||||
<div class="form-group mb-3" id="control-panel-section" style="display: none;">
|
||||
<label for="control_panel_ids" class="mb-2">Control Panels</label>
|
||||
@php
|
||||
$selectedPanelIds = old('control_panel_ids', $product->controlPanels->pluck('id')->toArray());
|
||||
$panelPriceModifiers = old(
|
||||
'control_panel_price_modifiers',
|
||||
$product->controlPanels->pluck('pivot.price_modifier', 'id')->toArray()
|
||||
);
|
||||
$defaultPanel = old(
|
||||
'control_panel_default',
|
||||
$product->controlPanels->where('pivot.is_default', true)->first()?->id
|
||||
);
|
||||
@endphp
|
||||
<select class="form-control select2" name="control_panel_ids[]" id="control_panel_ids" multiple data-placeholder="-- Select Control Panels --">
|
||||
@foreach ($controlPanels as $panel)
|
||||
<option value="{{ $panel->id }}" {{ in_array($panel->id, $selectedPanelIds) ? 'selected' : '' }}>
|
||||
{{ $panel->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<small class="text-muted">Select control panels available for this hosting product</small>
|
||||
|
||||
{{-- Price modifiers for each panel --}}
|
||||
<div id="panel-price-modifiers" class="mt-3">
|
||||
@foreach ($controlPanels as $panel)
|
||||
<div class="panel-price-row mb-2" id="panel-price-{{ $panel->id }}"
|
||||
style="display: {{ in_array($panel->id, $selectedPanelIds) ? 'block' : 'none' }};">
|
||||
<label class="form-label">{{ $panel->name }} - Phụ phí (VNĐ)</label>
|
||||
<div class="input-group">
|
||||
<input type="number"
|
||||
class="form-control"
|
||||
name="control_panel_price_modifiers[{{ $panel->id }}]"
|
||||
placeholder="0"
|
||||
min="0"
|
||||
step="1000"
|
||||
value="{{ $panelPriceModifiers[$panel->id] ?? 0 }}">
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<input type="radio"
|
||||
name="control_panel_default"
|
||||
value="{{ $panel->id }}"
|
||||
{{ $defaultPanel == $panel->id ? 'checked' : '' }}>
|
||||
<span class="ms-1">Mặc định</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Product Type --}}
|
||||
<div class="form-group mb-3">
|
||||
<label for="product_type" class="mb-2">Product Type</label>
|
||||
<select class="form-control select2" name="product_type" id="product_type">
|
||||
<option value="">-- Select Type --</option>
|
||||
@foreach (\App\Enums\Product\ProductTypeEnums::cases() as $type)
|
||||
<option value="{{ $type->value }}"
|
||||
{{ old('product_type', $product->product_type) == $type->value ? 'selected' : '' }}>
|
||||
{{ $type->label() }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{{-- Status --}}
|
||||
<div class="form-group mb-3">
|
||||
<label for="is_active" class="mb-2">Status</label>
|
||||
<select class="form-control select2" name="is_active" id="is_active">
|
||||
@foreach (\App\Enums\Status::cases() as $status)
|
||||
<option value="{{ $status->value }}"
|
||||
{{ old('is_active', $product->is_active ? 1 : 0) == $status->value ? 'selected' : '' }}>
|
||||
{{ $status->label() }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label for="sort_order" class="mb-2">Sort Order</label>
|
||||
<input type="number" name="sort_order" id="sort_order" class="form-control"
|
||||
value="{{ old('sort_order', $product->sort_order ?? 0) }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Product Type --}}
|
||||
<div class="form-group mb-3">
|
||||
<label for="product_type" class="mb-2">Product Type</label>
|
||||
<select class="form-control select2" name="product_type" id="product_type">
|
||||
<option value="">-- Select Type --</option>
|
||||
@foreach (\App\Enums\Product\ProductTypeEnums::cases() as $type)
|
||||
<option value="{{ $type->value }}"
|
||||
{{ old('product_type', $product->product_type) == $type->value ? 'selected' : '' }}>
|
||||
{{ $type->label() }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{{-- Status --}}
|
||||
<div class="form-group mb-3">
|
||||
<label for="is_active" class="mb-2">Status</label>
|
||||
<select class="form-control select2" name="is_active" id="is_active">
|
||||
@foreach (\App\Enums\Status::cases() as $status)
|
||||
<option value="{{ $status->value }}"
|
||||
{{ old('is_active', $product->is_active ? 1 : 0) == $status->value ? 'selected' : '' }}>
|
||||
{{ $status->label() }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label for="sort_order" class="mb-2">Sort Order</label>
|
||||
<input type="number" name="sort_order" id="sort_order" class="form-control"
|
||||
value="{{ old('sort_order', $product->sort_order ?? 0) }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card card-secondary card-outline">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title m-0">Inventory & Limits</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<label for="stock">Stock Quantity</label>
|
||||
<input type="number" name="stock" id="stock" class="form-control"
|
||||
placeholder="Unlimited if empty" value="{{ old('stock', $product->stock) }}">
|
||||
<div class="card card-secondary card-outline">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title m-0">Inventory & Limits</h5>
|
||||
</div>
|
||||
|
||||
<div class="form-group mt-3">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="is_unlimited"
|
||||
name="is_unlimited" value="1"
|
||||
{{ old('is_unlimited', $product->is_unlimited) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="is_unlimited">Unlimited Stock</label>
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<label for="stock">Stock Quantity</label>
|
||||
<input type="number" name="stock" id="stock" class="form-control"
|
||||
placeholder="Unlimited if empty" value="{{ old('stock', $product->stock) }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mt-3">
|
||||
<label for="published_at">Publish Date</label>
|
||||
<input type="date" name="published_at" id="published_at" class="form-control"
|
||||
value="{{ old('published_at', $product->published_at?->format('Y-m-d')) }}">
|
||||
<div class="form-group mt-3">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="is_unlimited"
|
||||
name="is_unlimited" value="1"
|
||||
{{ old('is_unlimited', $product->is_unlimited) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="is_unlimited">Unlimited Stock</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mt-3">
|
||||
<label for="published_at">Publish Date</label>
|
||||
<input type="date" name="published_at" id="published_at" class="form-control"
|
||||
value="{{ old('published_at', $product->published_at?->format('Y-m-d')) }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<x-fixed-action-bar>
|
||||
<x-button-crm type="button" variant="secondary" size="sm" icon="arrow-left"
|
||||
route="products.index">Cancel</x-button-crm>
|
||||
<x-button-crm type="submit" variant="primary" size="sm" icon="save">Update
|
||||
Product</x-button-crm>
|
||||
</x-fixed-action-bar>
|
||||
</form>
|
||||
<x-fixed-action-bar>
|
||||
<x-button-crm type="button" variant="secondary" size="sm" icon="arrow-left"
|
||||
route="products.index">Cancel</x-button-crm>
|
||||
<x-button-crm type="submit" variant="primary" size="sm" icon="save">Update
|
||||
Product</x-button-crm>
|
||||
</x-fixed-action-bar>
|
||||
</form>
|
||||
@endsection
|
||||
@push('plugin-scripts')
|
||||
@foreach (config('assets.datatable.js') as $datatable)
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<option value="{{ $item->id }}" {{ $selected == $item->id ? 'selected' : '' }}>
|
||||
{{ str_repeat('— ', $level) }}{{ $item->name }}
|
||||
</option>
|
||||
@if($item->children->count() > 0)
|
||||
@foreach ($item->children as $child)
|
||||
@include('administrator.pages.product.partials.category_options', ['item' => $child, 'level' => $level + 1, 'selected' => $selected])
|
||||
@endforeach
|
||||
@endif
|
||||
Reference in New Issue
Block a user