This commit is contained in:
pbao9
2026-02-03 11:07:47 +07:00
parent 0f9b6ffef2
commit 6178a76eee
18 changed files with 347 additions and 420 deletions
@@ -4,21 +4,17 @@ namespace App\Http\Controllers\admin\package;
use App\Http\Controllers\Controller;
use App\Http\Requests\Package\IPRequest;
use App\Models\ModuleDatacenter;
use App\Models\ModuleHost;
use App\Models\ModuleIpAddress;
use App\Models\ModuleNetwork;
use App\Models\vCenter;
use App\Repositories\Module\IpAddress\IpAddressRepositoryInterface;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Yajra\DataTables\Facades\DataTables;
class IPMapping extends Controller
{
public function __construct(
public IpAddressRepositoryInterface $ipAddressRepository
) {}
) {
}
public function index(Request $request)
{
$listIP = $this->ipAddressRepository->filter(
@@ -102,7 +98,7 @@ class IPMapping extends Controller
$ipaddress = $this->ipAddressRepository->findWithRelationships($id, ['host.datacenter.vCenter']);
if (! $ipaddress) {
if (!$ipaddress) {
return back()->withErrors('Can\'t find IP Address by ID #' . $id);
}
@@ -116,7 +112,7 @@ class IPMapping extends Controller
{
$ipaddress = $this->ipAddressRepository->find($id);
if (! $ipaddress) {
if (!$ipaddress) {
return back()->withErrors('Can\'t find IP Address by ID #' . $id);
}
@@ -142,9 +138,9 @@ class IPMapping extends Controller
public function destroy(int $id = 0)
{
$ipaddress = $this->ipAddressRepository->find($id);
$ipaddress = $this->ipAddressRepository->find($id);
if (! $ipaddress) {
if (!$ipaddress) {
return back()->withErrors('Can\'t find IP Address by ID #' . $id);
}
@@ -158,4 +154,28 @@ class IPMapping extends Controller
}
return back()->with('success', 'Deleted Successfully');
}
public function datatable(Request $request)
{
$query = $this->ipAddressRepository->filter(
$request->all(),
['host.datacenter.vCenter'],
[],
['*'],
true
);
return DataTables::eloquent($query)
->addColumn(
'action',
fn($d) =>
'<a href="' . route('package.ipaddress.edit', $d->id) . '" class="btn btn-primary btn-sm">Edit</a>'
)
->filterColumn('host.datacenter.v_center.host', function ($query, $keyword) {
$query->whereHas('host.datacenter.vCenter', function ($q) use ($keyword) {
$q->where('host', 'like', "%{$keyword}%");
});
})
->make(true);
}
}
@@ -122,18 +122,10 @@ class OsVersion extends Controller
return $d->getStatus();
})
->addColumn('action', function ($d) {
$editBtn = '<a href="' . route('package.version.edit', $d->id) . '"
class="btn btn-primary">
<i data-lucide="edit" class="w-12px h-12px"></i>
</a>';
$deleteBtn = '<button type="button"
class="btn btn-danger"
onclick="showDeleteModal(' . $d->id . ', \'' . addslashes($d->version) . '\')">
<i data-lucide="trash-2" class="w-12px h-12px"></i>
</button>';
return '<div class="btn-group" role="group">' . $editBtn . $deleteBtn . '</div>';
return view('administrator.pages.package.version.datatable.action', [
'id' => $d->id,
'version' => $d->version
])->render();
})
->filterColumn('host', function ($query, $keyword) {
$query->whereHas('host', function ($q) use ($keyword) {