update datatable
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Repositories\vCenter\vCenterRepositoryInterface;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class Datacenter extends Controller
|
||||
{
|
||||
@@ -41,7 +42,7 @@ class Datacenter extends Controller
|
||||
$request->validated();
|
||||
|
||||
$vcenter = $this->vCenterRepository->find($request->get('vcenter_id'));
|
||||
if (! $vcenter) {
|
||||
if (!$vcenter) {
|
||||
return back()->withErrors('Invalid request.');
|
||||
}
|
||||
$isCreated = $this->datacenterRepository->findBy('datacenter_id', $request->get('datacenter_id'));
|
||||
@@ -62,7 +63,7 @@ class Datacenter extends Controller
|
||||
{
|
||||
$datacenter = $this->datacenterRepository->find($id);
|
||||
|
||||
if (! $datacenter) {
|
||||
if (!$datacenter) {
|
||||
return back()->withErrors('Invalid request.');
|
||||
}
|
||||
$title = 'Edit Datacenter';
|
||||
@@ -72,7 +73,7 @@ class Datacenter extends Controller
|
||||
{
|
||||
$datacenter = $this->datacenterRepository->find($id);
|
||||
|
||||
if (! $datacenter) {
|
||||
if (!$datacenter) {
|
||||
return back()->withErrors('Invalid request.');
|
||||
}
|
||||
$request->validated();
|
||||
@@ -96,7 +97,7 @@ class Datacenter extends Controller
|
||||
{
|
||||
$datacenter = $this->datacenterRepository->find($id);
|
||||
|
||||
if (! $datacenter) {
|
||||
if (!$datacenter) {
|
||||
return back()->withErrors('Invalid request.');
|
||||
}
|
||||
|
||||
@@ -115,4 +116,24 @@ class Datacenter extends Controller
|
||||
dispatch($syncDatacenter)->delay(now()->addSeconds(5));
|
||||
return back()->with('success', 'The process is being established, please wait');
|
||||
}
|
||||
|
||||
public function datatable(Request $request)
|
||||
{
|
||||
$query = $this->datacenterRepository->filter(
|
||||
$request->all(),
|
||||
['vCenter'],
|
||||
[],
|
||||
['*'],
|
||||
true
|
||||
);
|
||||
|
||||
return DataTables::eloquent($query)
|
||||
->addColumn(
|
||||
'action',
|
||||
fn($d) =>
|
||||
'<a href="' . route('package.datacenter.edit', $d->id) . '" class="btn btn-primary btn-sm">Edit</a>'
|
||||
)
|
||||
->make(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,19 +16,32 @@ class DatacenterCachedRepository extends BaseCachedRepository implements Datacen
|
||||
{
|
||||
return $this->datacenterRepository->getModel();
|
||||
}
|
||||
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'])
|
||||
{
|
||||
public function filter(
|
||||
array $data = [],
|
||||
array $relationships = [],
|
||||
array $withCount = [],
|
||||
array $select = ['*'],
|
||||
bool $returnQuery = false
|
||||
) {
|
||||
if (
|
||||
$returnQuery ||
|
||||
!empty($data['paginate'])
|
||||
) {
|
||||
return $this->datacenterRepository
|
||||
->filter($data, $relationships, $withCount, $select, $returnQuery);
|
||||
}
|
||||
|
||||
$cacheKey = $this->getCacheKey(md5(json_encode([
|
||||
'filterItem' => [
|
||||
'data' => $data,
|
||||
'relationships' => $relationships,
|
||||
'select' => $select,
|
||||
'withCount' => $withCount
|
||||
]
|
||||
'filter' => compact('data', 'relationships', 'withCount', 'select')
|
||||
])));
|
||||
return Cache::remember($cacheKey, $this->cacheTime, function () use ($data, $relationships, $select, $withCount) {
|
||||
return $this->datacenterRepository->filter($data, $relationships, $withCount, $select);
|
||||
});
|
||||
|
||||
return Cache::remember(
|
||||
$cacheKey,
|
||||
$this->cacheTime,
|
||||
fn() =>
|
||||
$this->datacenterRepository
|
||||
->filter($data, $relationships, $withCount, $select, $returnQuery)
|
||||
);
|
||||
}
|
||||
public function findBy(string $key = '', string|int|null $value = '')
|
||||
{
|
||||
|
||||
@@ -12,22 +12,39 @@ class DatacenterRepository extends BaseRepository implements DatacenterRepositor
|
||||
return ModuleDatacenter::class;
|
||||
}
|
||||
|
||||
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'])
|
||||
{
|
||||
$model = $this->model->with($relationships)->select($select);
|
||||
public function filter(
|
||||
array $data = [],
|
||||
array $relationships = [],
|
||||
array $withCount = [],
|
||||
array $select = ['*'],
|
||||
bool $returnQuery = false
|
||||
) {
|
||||
$query = $this->model
|
||||
->select($select)
|
||||
->with($relationships);
|
||||
|
||||
if (isset($data['vcenter_id']) && $data['vcenter_id']) {
|
||||
$model = $model->where("vcenter_id", $data['vcenter_id']);
|
||||
if (!empty($data['vcenter_id'])) {
|
||||
$query->where('vcenter_id', $data['vcenter_id']);
|
||||
}
|
||||
if (count($withCount) > 0) {
|
||||
$model = $model->withCount($withCount);
|
||||
|
||||
if (!empty($withCount)) {
|
||||
$query->withCount($withCount);
|
||||
}
|
||||
if (isset($data['page'])) {
|
||||
return $model->paginate(15);
|
||||
|
||||
if ($returnQuery) {
|
||||
return $query;
|
||||
}
|
||||
return $model->get();
|
||||
|
||||
if (!empty($data['paginate'])) {
|
||||
return $query->paginate(
|
||||
$data['per_page'] ?? 15
|
||||
);
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
|
||||
public function findBy(string $key = '', string|int|null $value = '')
|
||||
{
|
||||
if (empty($key) || empty($value)) {
|
||||
|
||||
@@ -3,7 +3,15 @@ namespace App\Repositories\Module\Datacenter;
|
||||
|
||||
use App\Repositories\BaseRepositoryInterface;
|
||||
|
||||
interface DatacenterRepositoryInterface extends BaseRepositoryInterface{
|
||||
public function filter(array $data = [],array $relationships = [],array $withCount = [],array $select = ['*']);
|
||||
public function findBy(string $key = '',string|int|null $value = '' );
|
||||
interface DatacenterRepositoryInterface extends BaseRepositoryInterface
|
||||
{
|
||||
public function filter(
|
||||
array $data = [],
|
||||
array $relationships = [],
|
||||
array $withCount = [],
|
||||
array $select = ['*'],
|
||||
bool $returnQuery = false
|
||||
);
|
||||
|
||||
public function findBy(string $key = '', string|int|null $value = '');
|
||||
}
|
||||
+47
-47
@@ -9,29 +9,29 @@ return [
|
||||
'type' => 'group',
|
||||
'title' => 'Package vCenter',
|
||||
'icon' => 'box',
|
||||
'active' => ['administrator/package/*'],
|
||||
'active' => ['package.datacenter.*', 'package.host.*', 'package.datastore.*', 'package.folder.*', 'package.network.*', 'package.group.*', 'package.version.*', 'package.ipaddress.*', 'package.vm.*'],
|
||||
'children' => [
|
||||
['title' => 'Datacenter', 'url' => '/administrator/package/datacenter/list-all-datacenter', 'active' => ['administrator/package/datacenter/*']],
|
||||
['title' => 'Host', 'url' => '/administrator/package/host/list-all-host', 'active' => ['administrator/package/host/*']],
|
||||
['title' => 'Datastore', 'url' => '/administrator/package/datastore/list-all-datastore', 'active' => ['administrator/package/datastore/*']],
|
||||
['title' => 'Folder', 'url' => '/administrator/package/folder/list-all-folder', 'active' => ['administrator/package/folder/*']],
|
||||
['title' => 'Network Adapter', 'url' => '/administrator/package/network/list-all-network', 'active' => ['administrator/package/network/*']],
|
||||
['title' => 'Group Os', 'url' => '/administrator/package/group/list-all-group', 'active' => ['administrator/package/group/*']],
|
||||
['title' => 'Os Version', 'url' => '/administrator/package/version/list-all-os-version', 'active' => ['administrator/package/version/*']],
|
||||
['title' => 'IP Mapping', 'url' => '/administrator/package/ipaddress/list-all-ip-address', 'active' => ['administrator/package/ipaddress/*']],
|
||||
['title' => 'Virtual Machines', 'url' => '/administrator/package/vm/list-all-vm', 'active' => ['administrator/package/vm/*']],
|
||||
['title' => 'Datacenter', 'route' => 'package.datacenter.index', 'active' => ['package.datacenter.*']],
|
||||
['title' => 'Host', 'route' => 'package.host.index', 'active' => ['package.host.*']],
|
||||
['title' => 'Datastore', 'route' => 'package.datastore.index', 'active' => ['package.datastore.*']],
|
||||
['title' => 'Folder', 'route' => 'package.folder.index', 'active' => ['package.folder.*']],
|
||||
['title' => 'Network Adapter', 'route' => 'package.network.index', 'active' => ['package.network.*']],
|
||||
['title' => 'Group Os', 'route' => 'package.group.index', 'active' => ['package.group.*']],
|
||||
['title' => 'Os Version', 'route' => 'package.version.index', 'active' => ['package.version.*']],
|
||||
['title' => 'IP Mapping', 'route' => 'package.ipaddress.index', 'active' => ['package.ipaddress.*']],
|
||||
['title' => 'Virtual Machines', 'route' => 'package.vm.index', 'active' => ['package.vm.*']],
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'group',
|
||||
'title' => 'Module',
|
||||
'icon' => 'server',
|
||||
'active' => ['administrator/list-all-server-*', 'administrator/list-all-vcenter*', 'administrator/list-all-server-ip-pool*'],
|
||||
'active' => ['module.dns.*', 'module.hosting.*', 'module.vcenter.*', 'module.ippool.*'],
|
||||
'children' => [
|
||||
['title' => 'Module DNS', 'url' => '/administrator/list-all-server-dns', 'active' => ['administrator/list-all-server-dns*']],
|
||||
['title' => 'Module Hosting', 'url' => '/administrator/list-all-server-hosting', 'active' => ['administrator/list-all-server-hosting*']],
|
||||
['title' => 'Module vCenter', 'url' => '/administrator/list-all-vcenter', 'active' => ['administrator/list-all-vcenter*']],
|
||||
['title' => 'Module IP Pool', 'url' => '/administrator/list-all-server-ip-pool', 'active' => ['administrator/list-all-server-ip-pool*']],
|
||||
['title' => 'Module DNS', 'route' => 'module.dns.index', 'active' => ['module.dns.*']],
|
||||
['title' => 'Module Hosting', 'route' => 'module.hosting.index', 'active' => ['module.hosting.*']],
|
||||
['title' => 'Module vCenter', 'route' => 'module.vcenter.index', 'active' => ['module.vcenter.*']],
|
||||
['title' => 'Module IP Pool', 'route' => 'module.ippool.index', 'active' => ['module.ippool.*']],
|
||||
],
|
||||
],
|
||||
[
|
||||
@@ -42,57 +42,57 @@ return [
|
||||
'type' => 'group',
|
||||
'title' => 'Manager Admin',
|
||||
'icon' => 'users',
|
||||
'active' => ['administrator/list-all', 'administrator/list-role*'],
|
||||
'active' => ['admin.user.*', 'role.*'],
|
||||
'children' => [
|
||||
['title' => 'List Admin', 'url' => '/administrator/list-all', 'active' => ['administrator/list-all*']],
|
||||
['title' => 'Administrator Roles', 'url' => '/administrator/list-role', 'active' => ['administrator/list-role*']],
|
||||
['title' => 'List Admin', 'route' => 'admin.user.index', 'active' => ['admin.user.*']],
|
||||
['title' => 'Administrator Roles', 'route' => 'role.index', 'active' => ['role.*']],
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'group',
|
||||
'title' => 'Client',
|
||||
'icon' => 'users',
|
||||
'active' => ['administrator/list-customer*', 'administrator/add-client*'],
|
||||
'active' => ['customer.*'],
|
||||
'children' => [
|
||||
['title' => 'View All Client', 'url' => '/administrator/list-customer', 'active' => ['administrator/list-customer*']],
|
||||
['title' => 'Add new Client', 'url' => '/administrator/add-client', 'active' => ['administrator/add-client*']],
|
||||
['title' => 'View All Client', 'route' => 'customer.index', 'active' => ['customer.index', 'customer.info', 'customer.profile', 'customer.product', 'customer.domain', 'customer.invoice', 'customer.trans', 'customer.email', 'customer.log']],
|
||||
['title' => 'Add new Client', 'route' => 'customer.create', 'active' => ['customer.create']],
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'group',
|
||||
'title' => 'Product',
|
||||
'icon' => 'cloud',
|
||||
'active' => ['administrator/all-product*', 'administrator/list-addon*', 'administrator/list-domain*'],
|
||||
'active' => ['product.*', 'addon.*', 'domain.*'],
|
||||
'children' => [
|
||||
['title' => 'All Product/Services', 'url' => '/administrator/all-product', 'active' => ['administrator/all-product*']],
|
||||
['title' => 'Product Addon', 'url' => '/administrator/list-addon', 'active' => ['administrator/list-addon*']],
|
||||
['title' => 'Domain Pricing', 'url' => '/administrator/list-domain', 'active' => ['administrator/list-domain*']],
|
||||
['title' => 'All Product/Services', 'route' => 'product.index', 'active' => ['product.*']],
|
||||
['title' => 'Product Addon', 'route' => 'addon.index', 'active' => ['addon.*']],
|
||||
['title' => 'Domain Pricing', 'route' => 'domain.index', 'active' => ['domain.*']],
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'group',
|
||||
'title' => 'Orders',
|
||||
'icon' => 'shopping-cart',
|
||||
'active' => ['administrator/list-all-order*', 'administrator/add-new-order*'],
|
||||
'active' => ['admin.order.*'],
|
||||
'children' => [
|
||||
['title' => 'View All Orders', 'url' => '/administrator/list-all-order', 'active' => ['administrator/list-all-order']],
|
||||
['title' => 'Pending Orders', 'url' => '/administrator/list-all-order?status=pending', 'active' => []],
|
||||
['title' => 'Processing Orders', 'url' => '/administrator/list-all-order?status=processing', 'active' => []],
|
||||
['title' => 'Active Orders', 'url' => '/administrator/list-all-order?status=active', 'active' => []],
|
||||
['title' => 'Cancel Orders', 'url' => '/administrator/list-all-order?status=cancel', 'active' => []],
|
||||
['title' => 'Add New Orders', 'url' => '/administrator/add-new-order', 'active' => ['administrator/add-new-order*']],
|
||||
['title' => 'View All Orders', 'route' => 'admin.order.index', 'active' => ['admin.order.index'], 'params' => []],
|
||||
['title' => 'Pending Orders', 'route' => 'admin.order.index', 'active' => [], 'params' => ['status' => 'pending']],
|
||||
['title' => 'Processing Orders', 'route' => 'admin.order.index', 'active' => [], 'params' => ['status' => 'processing']],
|
||||
['title' => 'Active Orders', 'route' => 'admin.order.index', 'active' => [], 'params' => ['status' => 'active']],
|
||||
['title' => 'Cancel Orders', 'route' => 'admin.order.index', 'active' => [], 'params' => ['status' => 'cancel']],
|
||||
['title' => 'Add New Orders', 'route' => 'admin.order.create', 'active' => ['admin.order.create']],
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'group',
|
||||
'title' => 'Invoices',
|
||||
'icon' => 'file-text',
|
||||
'active' => ['administrator/list-all-invoice*'],
|
||||
'active' => ['admin.invoice.*'],
|
||||
'children' => [
|
||||
['title' => 'View All Invoice', 'url' => '/administrator/list-all-invoice', 'active' => ['administrator/list-all-invoice']],
|
||||
['title' => 'Pending Invoice', 'url' => '/administrator/list-all-invoice?status=unpaid', 'active' => []],
|
||||
['title' => 'Paid Invoice', 'url' => '/administrator/list-all-invoice?status=active', 'active' => []],
|
||||
['title' => 'Cancel Invoice', 'url' => '/administrator/list-all-invoice?status=cancel', 'active' => []],
|
||||
['title' => 'View All Invoice', 'route' => 'admin.invoice.index', 'active' => ['admin.invoice.index'], 'params' => []],
|
||||
['title' => 'Pending Invoice', 'route' => 'admin.invoice.index', 'active' => [], 'params' => ['status' => 'unpaid']],
|
||||
['title' => 'Paid Invoice', 'route' => 'admin.invoice.index', 'active' => [], 'params' => ['status' => 'active']],
|
||||
['title' => 'Cancel Invoice', 'route' => 'admin.invoice.index', 'active' => [], 'params' => ['status' => 'cancel']],
|
||||
],
|
||||
],
|
||||
[
|
||||
@@ -103,37 +103,37 @@ return [
|
||||
'type' => 'group',
|
||||
'title' => 'Menus',
|
||||
'icon' => 'folder',
|
||||
'active' => ['administrator/list-menu*'],
|
||||
'active' => ['menu.*'],
|
||||
'children' => [
|
||||
['title' => 'View All Menu', 'url' => '/administrator/list-menu', 'active' => ['administrator/list-menu*']],
|
||||
['title' => 'View All Menu', 'route' => 'menu.index', 'active' => ['menu.*']],
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'item',
|
||||
'title' => 'Coupon',
|
||||
'icon' => 'tags',
|
||||
'url' => '/administrator/list-coupon',
|
||||
'active' => ['administrator/list-coupon*'],
|
||||
'route' => 'coupon.index',
|
||||
'active' => ['coupon.*'],
|
||||
],
|
||||
[
|
||||
'type' => 'item',
|
||||
'title' => 'Posts',
|
||||
'icon' => 'pencil',
|
||||
'url' => '/administrator/list-post',
|
||||
'active' => ['administrator/list-post*'],
|
||||
'route' => 'post.index',
|
||||
'active' => ['post.*'],
|
||||
],
|
||||
[
|
||||
'type' => 'item',
|
||||
'title' => 'Support',
|
||||
'icon' => 'ticket',
|
||||
'url' => '/administrator/list-all-support',
|
||||
'active' => ['administrator/list-all-support*'],
|
||||
'route' => 'support.index',
|
||||
'active' => ['support.*'],
|
||||
],
|
||||
[
|
||||
'type' => 'item',
|
||||
'title' => 'Payment Method',
|
||||
'icon' => 'credit-card',
|
||||
'url' => '/administrator/list-payment',
|
||||
'active' => ['administrator/list-payment*'],
|
||||
'route' => 'payment.index',
|
||||
'active' => ['payment.*'],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -1,76 +1,24 @@
|
||||
@php use App\Http\Helpers\Helper; @endphp
|
||||
@extends('admin.main')
|
||||
@extends('administrator.layout.master')
|
||||
|
||||
@push('plugin-styles')
|
||||
<link href="{{ asset('build/plugins/select2/select2.min.css') }}" rel="stylesheet" />
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
@if(auth()->guard('admins')->user()->can("manager package module"))
|
||||
<div class="card card-primary card-outline">
|
||||
<div class="card-header">
|
||||
@include("admin.block.Sync.Datacenter")
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-invoice table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">
|
||||
<label>
|
||||
<input type="checkbox" name="check" class="check-all">
|
||||
</label>
|
||||
</th>
|
||||
<th class="text-center">Datacenter Name</th>
|
||||
<th class="text-center">vCenter Host</th>
|
||||
<th class="text-center">Last Updated</th>
|
||||
<th style="width:40px"></th>
|
||||
<th style="width: 40px"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@if($datacenter->count())
|
||||
@foreach($datacenter->all() as $item)
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<label for=""></label><input type="checkbox" name="id[]" value="{{ $item->id }}"
|
||||
id="">
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{{ $item->name }}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
@isset($item->vCenter->host)
|
||||
|
||||
{{ $item->vCenter->host }}
|
||||
@endisset
|
||||
</td>
|
||||
<td class="text-center">
|
||||
@time($item->created_at)
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-warning btn-sm"
|
||||
href="{{ route('package.datacenter.edit', ['id' => $item->id]) }}">
|
||||
<i class="fas fa-user-edit"></i>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
@if(auth()->guard('admins')->user()->can("delete module vcenter"))
|
||||
<form method="post" class="d-inline"
|
||||
action="{{ route('package.datacenter.destroy', ['id' => $item->id]) }}">
|
||||
@method('delete')
|
||||
@csrf
|
||||
<button type="submit" data-toggle="tooltip" data-placement="top" title=""
|
||||
class="btn btn-sm btn-danger" data-original-title="Xoá">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="card-body p-5">
|
||||
<x-datatable id="datacenterTable" ajax="{{ route('package.datacenter.datatable') }}" :columns="[
|
||||
['key' => 'id', 'label' => 'ID'],
|
||||
['key' => 'name', 'label' => 'Name'],
|
||||
['key' => 'v_center.host', 'label' => 'vCenter Host'],
|
||||
['key' => 'action', 'label' => 'Action']
|
||||
]" />
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
{{-- {{ $datacenter->withQueryString()->links() }}--}}
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<h5 class="mb-0"><i class="icon fas fa-ban"></i> Access Denied - You are not assigned to any Module Package
|
||||
@@ -78,3 +26,13 @@
|
||||
</div>
|
||||
@endif
|
||||
@endsection
|
||||
|
||||
@push('plugin-scripts')
|
||||
<script src="{{ asset('build/plugins/jquery/jquery.min.js') }}"></script>
|
||||
<script src="{{ asset('build/plugins/select2/select2.min.js') }}"></script>
|
||||
<script src="{{ asset('build/plugins/datatables.net/dataTables.min.js') }}"></script>
|
||||
<script src="{{ asset('build/plugins/datatables.net-bs5/dataTables.bootstrap5.min.js') }}"></script>
|
||||
@endpush
|
||||
|
||||
@push('custom-scripts')
|
||||
@endpush
|
||||
@@ -55,7 +55,7 @@
|
||||
@include('administrator.layout.partials.sidebar')
|
||||
<div class="page-wrapper">
|
||||
@include('administrator.layout.partials.header')
|
||||
<div class="page-content container-xxl">
|
||||
<div class="page-content">
|
||||
@yield('content')
|
||||
<div id="fui-toast"></div>
|
||||
</div>
|
||||
|
||||
@@ -6,53 +6,55 @@
|
||||
<div class="sidebar-toggler not-active">
|
||||
<span></span><span></span><span></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-body">
|
||||
<ul class="nav" id="sidebarNav">
|
||||
|
||||
@foreach(config('admin-sidebar', []) as $menu)
|
||||
</div>
|
||||
|
||||
<div class="sidebar-body">
|
||||
<ul class="nav" id="sidebarNav">
|
||||
|
||||
@foreach(config('admin-sidebar', []) as $menu)
|
||||
|
||||
{{-- CATEGORY --}}
|
||||
@if(($menu['type'] ?? null) === 'category')
|
||||
<li class="nav-item nav-category">
|
||||
{{ $menu['title'] }}
|
||||
</li>
|
||||
@endif
|
||||
|
||||
{{-- SINGLE ITEM --}}
|
||||
@if(($menu['type'] ?? null) === 'item')
|
||||
<li class="nav-item {{ active_class($menu['active'] ?? []) }}">
|
||||
<a href="{{ url($menu['url']) }}" class="nav-link">
|
||||
@isset($menu['icon'])
|
||||
<i class="link-icon" data-lucide="{{ $menu['icon'] }}"></i>
|
||||
@endisset
|
||||
<span class="link-title">{{ $menu['title'] }}</span>
|
||||
</a>
|
||||
</li>
|
||||
@endif
|
||||
|
||||
{{-- GROUP (COLLAPSE) --}}
|
||||
@if(($menu['type'] ?? null) === 'group')
|
||||
@php
|
||||
$id = \Illuminate\Support\Str::slug($menu['title']);
|
||||
@endphp
|
||||
|
||||
<li class="nav-item {{ active_class($menu['active'] ?? []) }}">
|
||||
<a class="nav-link" data-bs-toggle="collapse" href="#{{ $id }}" role="button"
|
||||
aria-expanded="{{ is_active_route($menu['active'] ?? []) }}" aria-controls="{{ $id }}">
|
||||
{{-- CATEGORY --}}
|
||||
@if(($menu['type'] ?? null) === 'category')
|
||||
<li class="nav-item nav-category">
|
||||
{{ $menu['title'] }}
|
||||
</li>
|
||||
@endif
|
||||
|
||||
{{-- SINGLE ITEM --}}
|
||||
@if(($menu['type'] ?? null) === 'item')
|
||||
<li class="nav-item {{ request()->routeIs(...($menu['active'] ?? [])) ? 'active' : '' }}">
|
||||
<a href="{{ route($menu['route'], $menu['params'] ?? []) }}" class="nav-link">
|
||||
@isset($menu['icon'])
|
||||
<i class="link-icon" data-lucide="{{ $menu['icon'] }}"></i>
|
||||
<span class="link-title">{{ $menu['title'] }}</span>
|
||||
<i class="link-arrow" data-lucide="chevron-down"></i>
|
||||
</a>
|
||||
@endisset
|
||||
<span class="link-title">{{ $menu['title'] }}</span>
|
||||
</a>
|
||||
</li>
|
||||
@endif
|
||||
|
||||
<div class="collapse {{ show_class($menu['active'] ?? []) }}" id="{{ $id }}" data-bs-parent="#sidebarNav">
|
||||
{{-- GROUP (COLLAPSE) --}}
|
||||
@if(($menu['type'] ?? null) === 'group')
|
||||
@php
|
||||
$id = \Illuminate\Support\Str::slug($menu['title']);
|
||||
$isActive = request()->routeIs(...($menu['active'] ?? []));
|
||||
@endphp
|
||||
|
||||
<li class="nav-item {{ $isActive ? 'active' : '' }}">
|
||||
<a class="nav-link" data-bs-toggle="collapse" href="#{{ $id }}" role="button"
|
||||
aria-expanded="{{ $isActive ? 'true' : 'false' }}" aria-controls="{{ $id }}">
|
||||
|
||||
<i class="link-icon" data-lucide="{{ $menu['icon'] }}"></i>
|
||||
<span class="link-title">{{ $menu['title'] }}</span>
|
||||
<i class="link-arrow" data-lucide="chevron-down"></i>
|
||||
</a>
|
||||
|
||||
<div class="collapse {{ $isActive ? 'show' : '' }}" id="{{ $id }}" data-bs-parent="#sidebarNav">
|
||||
|
||||
<ul class="nav sub-menu">
|
||||
@foreach($menu['children'] ?? [] as $child)
|
||||
<li class="nav-item">
|
||||
<a href="{{ url($child['url']) }}" class="nav-link {{ active_class($child['active'] ?? []) }}">
|
||||
<a href="{{ route($child['route'], $child['params'] ?? []) }}"
|
||||
class="nav-link {{ request()->routeIs(...($child['active'] ?? [])) ? 'active' : '' }}">
|
||||
{{ $child['title'] }}
|
||||
</a>
|
||||
</li>
|
||||
@@ -61,10 +63,10 @@
|
||||
|
||||
</div>
|
||||
</li>
|
||||
@endif
|
||||
@endif
|
||||
|
||||
@endforeach
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
@endforeach
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -1,35 +1,92 @@
|
||||
@php
|
||||
$dtColumns = collect($columns)->map(function ($c) {
|
||||
return [
|
||||
'data' => $c['key'],
|
||||
'name' => $c['key'],
|
||||
'orderable' => $c['orderable'] ?? true,
|
||||
'searchable' => $c['searchable'] ?? true,
|
||||
];
|
||||
return [
|
||||
'data' => $c['key'],
|
||||
'name' => $c['key'],
|
||||
'orderable' => $c['orderable'] ?? true,
|
||||
'searchable' => $c['searchable'] ?? true,
|
||||
];
|
||||
})->values();
|
||||
@endphp
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="{{ $id }}" class="table table-striped w-100">
|
||||
<thead>
|
||||
<tr>
|
||||
@foreach($columns as $col)
|
||||
<th>{{ $col['label'] }}</th>
|
||||
@endforeach
|
||||
</tr>
|
||||
<table id="{{ $id }}" class="table table-hover table-bordered w-100 align-middle my-3">
|
||||
<thead>
|
||||
<tr>
|
||||
@foreach($columns as $col)
|
||||
<th>{{ $col['label'] }}</th>
|
||||
@endforeach
|
||||
</tr>
|
||||
<tr>
|
||||
@foreach($columns as $col)
|
||||
<th>
|
||||
@if(($col['searchable'] ?? true))
|
||||
<input type="text" class="form-control form-control-sm column-search" placeholder="Search {{ $col['label'] }}"
|
||||
data-column="{{ $loop->index }}">
|
||||
@endif
|
||||
</th>
|
||||
@endforeach
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</table>
|
||||
@push('custom-scripts')
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
$.fn.DataTable.ext.pager.numbers_length = 7;
|
||||
|
||||
@push('custom-scripts')
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
$('#{{ $id }}').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: '{{ $ajax }}',
|
||||
columns: @json($dtColumns),
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
var table = $('#{{ $id }}').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: '{{ $ajax }}',
|
||||
columns: @json($dtColumns),
|
||||
orderCellsTop: true, // Important for the second header row
|
||||
fixedHeader: true,
|
||||
pagingType: 'full_numbers',
|
||||
language: {
|
||||
searchPlaceholder: "Search records",
|
||||
search: "",
|
||||
lengthMenu: "_MENU_",
|
||||
},
|
||||
dom: "<'row'<'col-sm-12'<'table-responsive'tr>>>" +
|
||||
"<'row mt-3 align-items-center'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7 d-flex align-items-center justify-content-end gap-2'lp>>",
|
||||
initComplete: function () {
|
||||
// Initialize select2 for length menu
|
||||
$('.dataTables_length select').select2({
|
||||
minimumResultsForSearch: Infinity,
|
||||
width: '60px'
|
||||
});
|
||||
|
||||
// Apply the search
|
||||
this.api().columns().every(function () {
|
||||
var that = this;
|
||||
$('input', this.header()).on('keyup change clear', function () {
|
||||
if (that.search() !== this.value) {
|
||||
that
|
||||
.search(this.value)
|
||||
.draw();
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
drawCallback: function() {
|
||||
if ($('.dataTables_length select').data('select2')) {
|
||||
$('.dataTables_length select').select2('destroy');
|
||||
}
|
||||
$('.dataTables_length select').select2({
|
||||
minimumResultsForSearch: Infinity,
|
||||
width: '60px'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Prevent sorting when clicking on the input
|
||||
$('#{{ $id }} thead tr:eq(1) th').on('click', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
// Custom search logic for the individual inputs
|
||||
$('#{{ $id }} .column-search').on('keyup change', function () {
|
||||
var columnIndex = $(this).data('column');
|
||||
table.column(columnIndex).search(this.value).draw();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@@ -219,6 +219,7 @@ Route::prefix('administrator')->group(function () {
|
||||
Route::get('edit/{id}', 'edit')->name('edit');
|
||||
Route::put('edit/{id}', 'update')->name('update');
|
||||
Route::delete('remove/{id}', 'destroy')->name('destroy');
|
||||
Route::get('datatable', 'datatable')->name('datatable');
|
||||
});
|
||||
//Datastore
|
||||
Route::group([
|
||||
|
||||
Reference in New Issue
Block a user