From 1c0a82d533fb68266a14a51263db558770e829fa Mon Sep 17 00:00:00 2001 From: cp6 Date: Mon, 31 Oct 2022 16:02:50 +1100 Subject: [PATCH] Updated Server controller and create & edit views Uses the resource id now No passing hidden input id Uses alert component for response --- app/Http/Controllers/ServerController.php | 16 ++++++---------- resources/views/servers/create.blade.php | 1 - resources/views/servers/edit.blade.php | 1 - 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/ServerController.php b/app/Http/Controllers/ServerController.php index 03f9070..5ff0247 100644 --- a/app/Http/Controllers/ServerController.php +++ b/app/Http/Controllers/ServerController.php @@ -47,7 +47,6 @@ class ServerController extends Controller 'ip2' => 'sometimes|nullable|ip', 'ns1' => 'sometimes|nullable|string', 'ns2' => 'sometimes|nullable|string', - 'service_type' => 'integer', 'server_type' => 'integer', 'ssh_port' => 'integer', 'bandwidth' => 'integer', @@ -133,7 +132,6 @@ class ServerController extends Controller 'ip2' => 'sometimes|nullable|ip', 'ns1' => 'sometimes|nullable|string', 'ns2' => 'sometimes|nullable|string', - 'service_type' => 'integer', 'server_type' => 'integer', 'ssh_port' => 'integer', 'bandwidth' => 'integer', @@ -176,26 +174,24 @@ class ServerController extends Controller 'show_public' => (isset($request->show_public)) ? 1 : 0 ]); - $server_id = $request->server_id; - $pricing = new Pricing(); - $pricing->updatePricing($server_id, $request->currency, $request->price, $request->payment_term, $request->next_due_date); + $pricing->updatePricing($server->id, $request->currency, $request->price, $request->payment_term, $request->next_due_date); - Labels::deleteLabelsAssignedTo($server_id); + Labels::deleteLabelsAssignedTo($server->id); - Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $server_id); + Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $server->id); - IPs::deleteIPsAssignedTo($server_id); + IPs::deleteIPsAssignedTo($server->id); for ($i = 1; $i <= 8; $i++) {//Max of 8 ips $obj = 'ip' . $i; if (isset($request->$obj) && !is_null($request->$obj)) { - IPs::insertIP($server_id, $request->$obj); + IPs::insertIP($server->id, $request->$obj); } } Server::serverRelatedCacheForget(); - Server::serverSpecificCacheForget($server_id); + Server::serverSpecificCacheForget($server->id); return redirect()->route('servers.index') ->with('success', 'Server Updated Successfully.'); diff --git a/resources/views/servers/create.blade.php b/resources/views/servers/create.blade.php index 6169115..8d58640 100644 --- a/resources/views/servers/create.blade.php +++ b/resources/views/servers/create.blade.php @@ -19,7 +19,6 @@ @csrf
-
Hostname
-