From df779ba6336dffaf50c2b0d6eceb342ccde02414 Mon Sep 17 00:00:00 2001 From: cp6 Date: Thu, 22 Sep 2022 13:20:23 +1000 Subject: [PATCH] Updated models and controllers to use first() Updated models and controllers to use first() rather than get() with [0] --- app/Http/Controllers/DomainsController.php | 4 ++-- app/Http/Controllers/MiscController.php | 4 ++-- app/Http/Controllers/ResellerController.php | 5 ++--- app/Http/Controllers/SeedBoxesController.php | 4 ++-- app/Http/Controllers/ServerController.php | 4 ++-- app/Http/Controllers/SharedController.php | 4 ++-- app/Models/Domains.php | 2 +- app/Models/Misc.php | 2 +- app/Models/Reseller.php | 2 +- app/Models/SeedBoxes.php | 2 +- app/Models/Server.php | 2 +- app/Models/Shared.php | 2 +- 12 files changed, 18 insertions(+), 19 deletions(-) diff --git a/app/Http/Controllers/DomainsController.php b/app/Http/Controllers/DomainsController.php index 06d172e..18dc838 100644 --- a/app/Http/Controllers/DomainsController.php +++ b/app/Http/Controllers/DomainsController.php @@ -22,7 +22,7 @@ class DomainsController extends Controller public function show(Domains $domain) {//Need to modern - $domain_info = Domains::domain($domain->id)[0]; + $domain_info = Domains::domain($domain->id); return view('domains.show', compact(['domain_info'])); } @@ -67,7 +67,7 @@ class DomainsController extends Controller public function edit(Domains $domain) { - $domain_info = Domains::domain($domain->id)[0]; + $domain_info = Domains::domain($domain->id); return view('domains.edit', compact(['domain_info'])); } diff --git a/app/Http/Controllers/MiscController.php b/app/Http/Controllers/MiscController.php index 5100381..92cacb8 100644 --- a/app/Http/Controllers/MiscController.php +++ b/app/Http/Controllers/MiscController.php @@ -25,7 +25,7 @@ class MiscController extends Controller public function show(Misc $misc) { - $misc_data = Misc::misc($misc->id)[0]; + $misc_data = Misc::misc($misc->id); return view('misc.show', compact(['misc_data'])); } @@ -58,7 +58,7 @@ class MiscController extends Controller public function edit(Misc $misc) { - $misc_data = Misc::misc($misc->id)[0]; + $misc_data = Misc::misc($misc->id); return view('misc.edit', compact('misc_data')); } diff --git a/app/Http/Controllers/ResellerController.php b/app/Http/Controllers/ResellerController.php index f74949c..a6086a0 100644 --- a/app/Http/Controllers/ResellerController.php +++ b/app/Http/Controllers/ResellerController.php @@ -29,7 +29,6 @@ class ResellerController extends Controller public function store(Request $request) { - $request->validate([ 'domain' => 'required|min:4', 'reseller_type' => 'required', @@ -94,13 +93,13 @@ class ResellerController extends Controller public function show(Reseller $reseller) { - $reseller = Reseller::resellerHosting($reseller->id)[0]; + $reseller = Reseller::resellerHosting($reseller->id); return view('reseller.show', compact(['reseller'])); } public function edit(Reseller $reseller) { - $reseller = Reseller::resellerHosting($reseller->id)[0]; + $reseller = Reseller::resellerHosting($reseller->id); return view('reseller.edit', compact(['reseller'])); } diff --git a/app/Http/Controllers/SeedBoxesController.php b/app/Http/Controllers/SeedBoxesController.php index b6182f6..73c7109 100644 --- a/app/Http/Controllers/SeedBoxesController.php +++ b/app/Http/Controllers/SeedBoxesController.php @@ -78,13 +78,13 @@ class SeedBoxesController extends Controller public function show(SeedBoxes $seedbox) { - $seedbox_data = SeedBoxes::seedbox($seedbox->id)[0]; + $seedbox_data = SeedBoxes::seedbox($seedbox->id); return view('seedboxes.show', compact(['seedbox_data'])); } public function edit(SeedBoxes $seedbox) { - $seedbox_data = SeedBoxes::seedbox($seedbox->id)[0]; + $seedbox_data = SeedBoxes::seedbox($seedbox->id); return view('seedboxes.edit', compact(['seedbox_data'])); } diff --git a/app/Http/Controllers/ServerController.php b/app/Http/Controllers/ServerController.php index 1058447..9074f7a 100644 --- a/app/Http/Controllers/ServerController.php +++ b/app/Http/Controllers/ServerController.php @@ -118,14 +118,14 @@ class ServerController extends Controller public function show(Server $server) { - $server_data = Server::server($server->id)[0]; + $server_data = Server::server($server->id); return view('servers.show', compact(['server_data'])); } public function edit(Server $server) { - $server_data = Server::server($server->id)[0]; + $server_data = Server::server($server->id); return view('servers.edit', compact(['server_data'])); } diff --git a/app/Http/Controllers/SharedController.php b/app/Http/Controllers/SharedController.php index 4067bb9..b83e6f7 100644 --- a/app/Http/Controllers/SharedController.php +++ b/app/Http/Controllers/SharedController.php @@ -90,13 +90,13 @@ class SharedController extends Controller public function show(Shared $shared) { - $shared = Shared::sharedHosting($shared->id)[0]; + $shared = Shared::sharedHosting($shared->id); return view('shared.show', compact(['shared'])); } public function edit(Shared $shared) { - $shared = Shared::sharedHosting($shared->id)[0]; + $shared = Shared::sharedHosting($shared->id); return view('shared.edit', compact(['shared'])); } diff --git a/app/Models/Domains.php b/app/Models/Domains.php index 64d76c1..c6cb7d0 100644 --- a/app/Models/Domains.php +++ b/app/Models/Domains.php @@ -31,7 +31,7 @@ class Domains extends Model {//Single domains and relationships (no using joins) return Cache::remember("domain.$domain_id", now()->addMonth(1), function () use ($domain_id) { return Domains::where('id', $domain_id) - ->with(['provider', 'price', 'labels', 'labels.label'])->get(); + ->with(['provider', 'price', 'labels', 'labels.label'])->first(); }); } diff --git a/app/Models/Misc.php b/app/Models/Misc.php index bcd9459..91af70b 100644 --- a/app/Models/Misc.php +++ b/app/Models/Misc.php @@ -29,7 +29,7 @@ class Misc extends Model {//Single misc and relationships (no using joins) return Cache::remember("misc.$misc_id", now()->addMonth(1), function () use ($misc_id) { return Misc::where('id', $misc_id) - ->with(['price'])->get(); + ->with(['price'])->first(); }); } diff --git a/app/Models/Reseller.php b/app/Models/Reseller.php index ecb81c7..9b3ae08 100644 --- a/app/Models/Reseller.php +++ b/app/Models/Reseller.php @@ -30,7 +30,7 @@ class Reseller extends Model {//Single reseller hosting and relationships (no using joins) return Cache::remember("reseller_hosting.$shared_id", now()->addMonth(1), function () use ($shared_id) { return Reseller::where('id', $shared_id) - ->with(['location', 'provider', 'price', 'ips', 'labels', 'labels.label'])->get(); + ->with(['location', 'provider', 'price', 'ips', 'labels', 'labels.label'])->first(); }); } diff --git a/app/Models/SeedBoxes.php b/app/Models/SeedBoxes.php index 9924c2d..7df318f 100644 --- a/app/Models/SeedBoxes.php +++ b/app/Models/SeedBoxes.php @@ -30,7 +30,7 @@ class SeedBoxes extends Model {//Single seedbox and relationships (no using joins) return Cache::remember("seedbox.$seedbox_id", now()->addMonth(1), function () use ($seedbox_id) { return SeedBoxes::where('id', $seedbox_id) - ->with(['location', 'provider', 'price', 'labels.label'])->get(); + ->with(['location', 'provider', 'price', 'labels.label'])->first(); }); } diff --git a/app/Models/Server.php b/app/Models/Server.php index 6088f65..c19d8d0 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -37,7 +37,7 @@ class Server extends Model {//Single server and relationships (no using joins) return Cache::remember("server.$server_id", now()->addMonth(1), function () use ($server_id) { return Server::where('id', $server_id) - ->with(['location', 'provider', 'os', 'price', 'ips', 'yabs', 'yabs.disk_speed', 'yabs.network_speed', 'labels', 'labels.label'])->get(); + ->with(['location', 'provider', 'os', 'price', 'ips', 'yabs', 'yabs.disk_speed', 'yabs.network_speed', 'labels', 'labels.label'])->first(); }); } diff --git a/app/Models/Shared.php b/app/Models/Shared.php index b02ccb3..769e766 100644 --- a/app/Models/Shared.php +++ b/app/Models/Shared.php @@ -30,7 +30,7 @@ class Shared extends Model {//Single shared hosting and relationships (no using joins) return Cache::remember("shared_hosting.$shared_id", now()->addMonth(1), function () use ($shared_id) { return Shared::where('id', $shared_id) - ->with(['location', 'provider', 'price', 'ips', 'labels', 'labels.label'])->get(); + ->with(['location', 'provider', 'price', 'ips', 'labels', 'labels.label'])->first(); }); }