update
This commit is contained in:
@@ -42,8 +42,7 @@ class OsVersion extends Controller
|
||||
{
|
||||
$validatedData = $request->validated();
|
||||
|
||||
// Remove unnecessary fields
|
||||
unset($validatedData['vcenter_id'], $validatedData['module_datacenter_id']);
|
||||
unset($validatedData['module_datacenter_id']);
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
@@ -88,22 +87,21 @@ class OsVersion extends Controller
|
||||
}
|
||||
return redirect()->route('package.version.index')->with('success', 'Update successfully');
|
||||
}
|
||||
public function destroy(Request $request)
|
||||
public function destroy($id)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'oid' => 'numeric'
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator->getMessageBag());
|
||||
}
|
||||
try {
|
||||
$version = $this->osRepository->find($id);
|
||||
if (!$version) {
|
||||
return back()->withErrors('Can\'t find version os by ID #' . $id);
|
||||
}
|
||||
|
||||
$version = Os::find($request->oid);
|
||||
if (! $version) {
|
||||
return back()->withErrors('Can\'t find version os by ID #' . $request->oid);
|
||||
}
|
||||
$version->delete();
|
||||
$version->delete();
|
||||
|
||||
return back()->with('success', 'Delete success');
|
||||
return redirect()->route('package.version.index')
|
||||
->with('success', 'OS Version deleted successfully');
|
||||
} catch (\Exception $error) {
|
||||
return back()->withErrors('Failed to delete OS Version: ' . $error->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function datatable(Request $request)
|
||||
@@ -124,10 +122,18 @@ class OsVersion extends Controller
|
||||
return $d->getStatus();
|
||||
})
|
||||
->addColumn('action', function ($d) {
|
||||
return '<a href="' . route('package.version.edit', $d->id) . '"
|
||||
class="btn btn-primary btn-sm">
|
||||
Edit
|
||||
$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>';
|
||||
})
|
||||
->filterColumn('host', function ($query, $keyword) {
|
||||
$query->whereHas('host', function ($q) use ($keyword) {
|
||||
|
||||
Reference in New Issue
Block a user