From afe5c1e52507bbf60c9e119a83b842870b46f556 Mon Sep 17 00:00:00 2001 From: cp6 Date: Fri, 18 Aug 2023 19:33:26 +1000 Subject: [PATCH] Cleaned up queries that had un-needed '=' --- app/Http/Controllers/ApiController.php | 14 +++---- app/Http/Controllers/DNSController.php | 8 ++-- app/Http/Controllers/LabelsController.php | 12 +++--- app/Http/Controllers/LocationsController.php | 6 +-- app/Models/Home.php | 42 ++++++++++---------- app/Models/IPs.php | 4 +- app/Models/Labels.php | 4 +- app/Models/Pricing.php | 2 +- app/Models/Providers.php | 6 +-- app/Models/Server.php | 6 +-- 10 files changed, 52 insertions(+), 52 deletions(-) diff --git a/app/Http/Controllers/ApiController.php b/app/Http/Controllers/ApiController.php index 0eff21c..923f8e0 100644 --- a/app/Http/Controllers/ApiController.php +++ b/app/Http/Controllers/ApiController.php @@ -60,7 +60,7 @@ class ApiController extends Controller protected function getNetworkSpeeds($id) { - $ns = NetworkSpeed::where('server_id', '=', $id) + $ns = NetworkSpeed::where('server_id', $id) ->get()->toJson(JSON_PRETTY_PRINT); return response($ns, 200); } @@ -73,7 +73,7 @@ class ApiController extends Controller protected function getLabel($id) { - $label = Labels::where('id', '=', $id) + $label = Labels::where('id', $id) ->get()->toJson(JSON_PRETTY_PRINT); return response($label, 200); } @@ -148,7 +148,7 @@ class ApiController extends Controller protected function getDns($id) { $dns = DB::table('d_n_s') - ->where('id', '=', $id) + ->where('id', $id) ->get()->toJson(JSON_PRETTY_PRINT); return response($dns, 200); } @@ -163,7 +163,7 @@ class ApiController extends Controller protected function getLocation($id) { $location = DB::table('locations') - ->where('id', '=', $id) + ->where('id', $id) ->get()->toJson(JSON_PRETTY_PRINT); return response($location, 200); } @@ -178,7 +178,7 @@ class ApiController extends Controller protected function getProvider($id) { $providers = DB::table('providers') - ->where('id', '=', $id) + ->where('id', $id) ->get()->toJson(JSON_PRETTY_PRINT); return response($providers, 200); } @@ -199,7 +199,7 @@ class ApiController extends Controller protected function getOs($id) { $os = DB::table('os as o') - ->where('o.id', '=', $id) + ->where('o.id', $id) ->get()->toJson(JSON_PRETTY_PRINT); return response($os, 200); } @@ -213,7 +213,7 @@ class ApiController extends Controller protected function getIP($id) { $ip = DB::table('ips as i') - ->where('i.id', '=', $id) + ->where('i.id', $id) ->get()->toJson(JSON_PRETTY_PRINT); return response($ip, 200); } diff --git a/app/Http/Controllers/DNSController.php b/app/Http/Controllers/DNSController.php index 4876c36..964dabd 100644 --- a/app/Http/Controllers/DNSController.php +++ b/app/Http/Controllers/DNSController.php @@ -69,8 +69,8 @@ class DNSController extends Controller $dns = DNS::findOrFail($dn->id); $labels = DB::table('labels_assigned as l') - ->join('labels', 'l.label_id', '=', 'labels.id') - ->where('l.service_id', '=', $dn->id) + ->join('labels', 'l.label_id', 'labels.id') + ->where('l.service_id', $dn->id) ->get(['labels.label']); return view('dns.show', compact(['dn', 'dns', 'labels'])); @@ -84,8 +84,8 @@ class DNSController extends Controller $Resellers = Reseller::all(); $dn = DNS::findOrFail($dn->id); $labels = DB::table('labels_assigned as l') - ->join('labels', 'l.label_id', '=', 'labels.id') - ->where('l.service_id', '=', $dn->id) + ->join('labels', 'l.label_id', 'labels.id') + ->where('l.service_id', $dn->id) ->get(['labels.id']); return view('dns.edit', compact(['dn', 'labels', 'Servers', 'Domains', 'Shareds', 'Resellers'])); diff --git a/app/Http/Controllers/LabelsController.php b/app/Http/Controllers/LabelsController.php index 5a77099..7db1e63 100644 --- a/app/Http/Controllers/LabelsController.php +++ b/app/Http/Controllers/LabelsController.php @@ -43,12 +43,12 @@ class LabelsController extends Controller public function show(Labels $label) { $labels = DB::table('labels_assigned as las') - ->leftJoin('pricings as p', 'las.service_id', '=', 'p.service_id') - ->leftJoin('servers as s', 'las.service_id', '=', 's.id') - ->leftJoin('shared_hosting as sh', 'las.service_id', '=', 'sh.id') - ->leftJoin('reseller_hosting as r', 'las.service_id', '=', 'r.id') - ->leftJoin('domains as d', 'las.service_id', '=', 'd.id') - ->where('las.label_id', '=', $label->id) + ->leftJoin('pricings as p', 'las.service_id', 'p.service_id') + ->leftJoin('servers as s', 'las.service_id', 's.id') + ->leftJoin('shared_hosting as sh', 'las.service_id', 'sh.id') + ->leftJoin('reseller_hosting as r', 'las.service_id', 'r.id') + ->leftJoin('domains as d', 'las.service_id', 'd.id') + ->where('las.label_id', $label->id) ->get(['p.service_type', 'p.service_id', 's.hostname', 'sh.main_domain as shared', 'r.main_domain as reseller', 'd.domain', 'd.extension']); return view('labels.show', compact(['label', 'labels'])); diff --git a/app/Http/Controllers/LocationsController.php b/app/Http/Controllers/LocationsController.php index 74b5453..782f341 100644 --- a/app/Http/Controllers/LocationsController.php +++ b/app/Http/Controllers/LocationsController.php @@ -40,17 +40,17 @@ class LocationsController extends Controller public function show(Locations $location) { $servers = DB::table('servers as s') - ->where('s.location_id', '=', $location->id) + ->where('s.location_id', $location->id) ->get(['s.id', 's.hostname']) ->toArray(); $shared = DB::table('shared_hosting as s') - ->where('s.location_id', '=', $location->id) + ->where('s.location_id', $location->id) ->get(['s.id', 's.main_domain as main_domain_shared']) ->toArray(); $reseller = DB::table('reseller_hosting as r') - ->where('r.location_id', '=', $location->id) + ->where('r.location_id', $location->id) ->get(['r.id', 'r.main_domain as main_domain_reseller']) ->toArray(); diff --git a/app/Models/Home.php b/app/Models/Home.php index d54e430..ed63222 100644 --- a/app/Models/Home.php +++ b/app/Models/Home.php @@ -29,7 +29,7 @@ class Home extends Model return DB::table('pricings') ->select('service_type', DB::raw('COUNT(*) as amount')) ->groupBy('service_type') - ->where('active', '=', 1) + ->where('active', 1) ->get(); }); } @@ -38,13 +38,13 @@ class Home extends Model { return Cache::remember('due_soon', now()->addHours(6), function () { return DB::table('pricings as p') - ->leftJoin('servers as s', 'p.service_id', '=', 's.id') - ->leftJoin('shared_hosting as sh', 'p.service_id', '=', 'sh.id') - ->leftJoin('reseller_hosting as r', 'p.service_id', '=', 'r.id') - ->leftJoin('domains as d', 'p.service_id', '=', 'd.id') - ->leftJoin('misc_services as ms', 'p.service_id', '=', 'ms.id') - ->leftJoin('seedboxes as sb', 'p.service_id', '=', 'sb.id') - ->where('p.active', '=', 1) + ->leftJoin('servers as s', 'p.service_id', 's.id') + ->leftJoin('shared_hosting as sh', 'p.service_id', 'sh.id') + ->leftJoin('reseller_hosting as r', 'p.service_id', 'r.id') + ->leftJoin('domains as d', 'p.service_id', 'd.id') + ->leftJoin('misc_services as ms', 'p.service_id', 'ms.id') + ->leftJoin('seedboxes as sb', 'p.service_id', 'sb.id') + ->where('p.active', 1) ->orderBy('next_due_date', 'ASC') ->limit(Session::get('due_soon_amount')) ->get(['p.*', 's.hostname', 'd.domain', 'd.extension', 'r.main_domain as reseller', 'sh.main_domain', 'ms.name', 'sb.title']); @@ -54,12 +54,12 @@ class Home extends Model public static function serverSummary() { return Cache::remember('servers_summary', now()->addHours(6), function () { - $cpu_sum = DB::table('servers')->get()->where('active', '=', 1)->sum('cpu'); - $ram_mb = DB::table('servers')->get()->where('active', '=', 1)->sum('ram_as_mb'); - $disk_gb = DB::table('servers')->get()->where('active', '=', 1)->sum('disk_as_gb'); - $bandwidth = DB::table('servers')->get()->where('active', '=', 1)->sum('bandwidth'); - $locations_sum = DB::table('servers')->get()->where('active', '=', 1)->groupBy('location_id')->count(); - $providers_sum = DB::table('servers')->get()->where('active', '=', 1)->groupBy('provider_id')->count(); + $cpu_sum = DB::table('servers')->get()->where('active', 1)->sum('cpu'); + $ram_mb = DB::table('servers')->get()->where('active', 1)->sum('ram_as_mb'); + $disk_gb = DB::table('servers')->get()->where('active', 1)->sum('disk_as_gb'); + $bandwidth = DB::table('servers')->get()->where('active', 1)->sum('bandwidth'); + $locations_sum = DB::table('servers')->get()->where('active', 1)->groupBy('location_id')->count(); + $providers_sum = DB::table('servers')->get()->where('active', 1)->groupBy('provider_id')->count(); return array( 'cpu_sum' => $cpu_sum, 'ram_mb_sum' => $ram_mb, @@ -75,13 +75,13 @@ class Home extends Model { return Cache::remember('recently_added', now()->addHours(6), function () { return DB::table('pricings as p') - ->leftJoin('servers as s', 'p.service_id', '=', 's.id') - ->leftJoin('shared_hosting as sh', 'p.service_id', '=', 'sh.id') - ->leftJoin('reseller_hosting as r', 'p.service_id', '=', 'r.id') - ->leftJoin('domains as d', 'p.service_id', '=', 'd.id') - ->leftJoin('misc_services as ms', 'p.service_id', '=', 'ms.id') - ->leftJoin('seedboxes as sb', 'p.service_id', '=', 'sb.id') - ->where('p.active', '=', 1) + ->leftJoin('servers as s', 'p.service_id', 's.id') + ->leftJoin('shared_hosting as sh', 'p.service_id', 'sh.id') + ->leftJoin('reseller_hosting as r', 'p.service_id', 'r.id') + ->leftJoin('domains as d', 'p.service_id', 'd.id') + ->leftJoin('misc_services as ms', 'p.service_id', 'ms.id') + ->leftJoin('seedboxes as sb', 'p.service_id', 'sb.id') + ->where('p.active', 1) ->orderBy('created_at', 'DESC') ->limit(Session::get('recently_added_amount')) ->get(['p.*', 's.hostname', 'd.domain', 'd.extension', 'r.main_domain as reseller', 'sh.main_domain', 'ms.name', 'sb.title']); diff --git a/app/Models/IPs.php b/app/Models/IPs.php index c5beddb..5a44c1f 100644 --- a/app/Models/IPs.php +++ b/app/Models/IPs.php @@ -22,7 +22,7 @@ class IPs extends Model public static function deleteIPsAssignedTo($service_id) { - DB::table('ips')->where('service_id', '=', $service_id)->delete(); + DB::table('ips')->where('service_id', $service_id)->delete(); } public static function insertIP(string $service_id, string $address): IPs @@ -42,7 +42,7 @@ class IPs extends Model { return Cache::remember("ip_addresses.$server_id", now()->addHours(1), function () use ($server_id) { return json_decode(DB::table('ips as i') - ->where('i.service_id', '=', $server_id) + ->where('i.service_id', $server_id) ->get(), true); }); } diff --git a/app/Models/Labels.php b/app/Models/Labels.php index d83f91c..52ea6b6 100644 --- a/app/Models/Labels.php +++ b/app/Models/Labels.php @@ -21,12 +21,12 @@ class Labels extends Model public static function deleteLabelsAssignedTo($service_id) { - DB::table('labels_assigned')->where('service_id', '=', $service_id)->delete(); + DB::table('labels_assigned')->where('service_id', $service_id)->delete(); } public static function deleteLabelAssignedAs($label_id) { - DB::table('labels_assigned')->where('label_id', '=', $label_id)->delete(); + DB::table('labels_assigned')->where('label_id', $label_id)->delete(); } public static function insertLabelsAssigned(array $labels_array, string $service_id) diff --git a/app/Models/Pricing.php b/app/Models/Pricing.php index c845728..8279d5c 100644 --- a/app/Models/Pricing.php +++ b/app/Models/Pricing.php @@ -106,7 +106,7 @@ class Pricing extends Model public function deletePricing($id): void { - DB::table('pricings')->where('service_id', '=', $id)->delete(); + DB::table('pricings')->where('service_id', $id)->delete(); } public function insertPricing(int $type, string $service_id, string $currency, float $price, int $term, string $next_due_date, int $is_active = 1): Pricing diff --git a/app/Models/Providers.php b/app/Models/Providers.php index d57dc2f..c38a309 100644 --- a/app/Models/Providers.php +++ b/app/Models/Providers.php @@ -27,17 +27,17 @@ class Providers extends Model public static function showServicesForProvider($provider): array { $servers = DB::table('servers as s') - ->where('s.provider_id', '=', $provider) + ->where('s.provider_id', $provider) ->get(['s.id', 's.hostname']) ->toArray(); $shared = DB::table('shared_hosting as s') - ->where('s.provider_id', '=', $provider) + ->where('s.provider_id', $provider) ->get(['s.id', 's.main_domain as main_domain_shared']) ->toArray(); $reseller = DB::table('reseller_hosting as r') - ->where('r.provider_id', '=', $provider) + ->where('r.provider_id', $provider) ->get(['r.id', 'r.main_domain as main_domain_reseller']) ->toArray(); diff --git a/app/Models/Server.php b/app/Models/Server.php index 96edfd2..e332669 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -63,7 +63,7 @@ class Server extends Model public static function allActiveServers() {//All ACTIVE servers and relationships replaces activeServersDataIndexPage() return Cache::remember("all_active_servers", now()->addMonth(1), function () { - $query = Server::where('active', '=', 1) + $query = Server::where('active', 1) ->with(['location', 'provider', 'os', 'ips', 'yabs', 'yabs.disk_speed', 'yabs.network_speed', 'labels', 'price']); if (in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) { $options = Settings::orderByProcess(Session::get('sort_on')); @@ -76,7 +76,7 @@ class Server extends Model public static function allNonActiveServers() {//All NON ACTIVE servers and relationships replaces nonActiveServersDataIndexPage() return Cache::remember("non_active_servers", now()->addMonth(1), function () { - return Server::where('active', '=', 0) + return Server::where('active', 0) ->with(['location', 'provider', 'os', 'price', 'ips', 'yabs', 'yabs.disk_speed', 'yabs.network_speed', 'labels']) ->get(); }); @@ -85,7 +85,7 @@ class Server extends Model public static function allPublicServers() {//server data that will be publicly viewable (values in settings) return Cache::remember("public_server_data", now()->addMonth(1), function () { - return Server::where('show_public', '=', 1) + return Server::where('show_public', 1) ->with(['location', 'provider', 'os', 'price', 'ips', 'yabs', 'yabs.disk_speed', 'yabs.network_speed', 'labels']) ->get(); });