diff --git a/app/Http/Controllers/admin/package/IPMapping.php b/app/Http/Controllers/admin/package/IPMapping.php index df1a347..f397d25 100644 --- a/app/Http/Controllers/admin/package/IPMapping.php +++ b/app/Http/Controllers/admin/package/IPMapping.php @@ -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) => + 'Edit' + ) + ->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); + } } diff --git a/app/Http/Controllers/admin/package/OsVersion.php b/app/Http/Controllers/admin/package/OsVersion.php index cd14c29..b99955a 100644 --- a/app/Http/Controllers/admin/package/OsVersion.php +++ b/app/Http/Controllers/admin/package/OsVersion.php @@ -122,18 +122,10 @@ class OsVersion extends Controller return $d->getStatus(); }) ->addColumn('action', function ($d) { - $editBtn = ' - - '; - - $deleteBtn = ''; - - return '