Cleaned up queries that had un-needed '='

This commit is contained in:
cp6 2023-08-18 19:33:26 +10:00
parent 877592f614
commit afe5c1e525
10 changed files with 52 additions and 52 deletions

View File

@ -60,7 +60,7 @@ class ApiController extends Controller
protected function getNetworkSpeeds($id) protected function getNetworkSpeeds($id)
{ {
$ns = NetworkSpeed::where('server_id', '=', $id) $ns = NetworkSpeed::where('server_id', $id)
->get()->toJson(JSON_PRETTY_PRINT); ->get()->toJson(JSON_PRETTY_PRINT);
return response($ns, 200); return response($ns, 200);
} }
@ -73,7 +73,7 @@ class ApiController extends Controller
protected function getLabel($id) protected function getLabel($id)
{ {
$label = Labels::where('id', '=', $id) $label = Labels::where('id', $id)
->get()->toJson(JSON_PRETTY_PRINT); ->get()->toJson(JSON_PRETTY_PRINT);
return response($label, 200); return response($label, 200);
} }
@ -148,7 +148,7 @@ class ApiController extends Controller
protected function getDns($id) protected function getDns($id)
{ {
$dns = DB::table('d_n_s') $dns = DB::table('d_n_s')
->where('id', '=', $id) ->where('id', $id)
->get()->toJson(JSON_PRETTY_PRINT); ->get()->toJson(JSON_PRETTY_PRINT);
return response($dns, 200); return response($dns, 200);
} }
@ -163,7 +163,7 @@ class ApiController extends Controller
protected function getLocation($id) protected function getLocation($id)
{ {
$location = DB::table('locations') $location = DB::table('locations')
->where('id', '=', $id) ->where('id', $id)
->get()->toJson(JSON_PRETTY_PRINT); ->get()->toJson(JSON_PRETTY_PRINT);
return response($location, 200); return response($location, 200);
} }
@ -178,7 +178,7 @@ class ApiController extends Controller
protected function getProvider($id) protected function getProvider($id)
{ {
$providers = DB::table('providers') $providers = DB::table('providers')
->where('id', '=', $id) ->where('id', $id)
->get()->toJson(JSON_PRETTY_PRINT); ->get()->toJson(JSON_PRETTY_PRINT);
return response($providers, 200); return response($providers, 200);
} }
@ -199,7 +199,7 @@ class ApiController extends Controller
protected function getOs($id) protected function getOs($id)
{ {
$os = DB::table('os as o') $os = DB::table('os as o')
->where('o.id', '=', $id) ->where('o.id', $id)
->get()->toJson(JSON_PRETTY_PRINT); ->get()->toJson(JSON_PRETTY_PRINT);
return response($os, 200); return response($os, 200);
} }
@ -213,7 +213,7 @@ class ApiController extends Controller
protected function getIP($id) protected function getIP($id)
{ {
$ip = DB::table('ips as i') $ip = DB::table('ips as i')
->where('i.id', '=', $id) ->where('i.id', $id)
->get()->toJson(JSON_PRETTY_PRINT); ->get()->toJson(JSON_PRETTY_PRINT);
return response($ip, 200); return response($ip, 200);
} }

View File

@ -69,8 +69,8 @@ class DNSController extends Controller
$dns = DNS::findOrFail($dn->id); $dns = DNS::findOrFail($dn->id);
$labels = DB::table('labels_assigned as l') $labels = DB::table('labels_assigned as l')
->join('labels', 'l.label_id', '=', 'labels.id') ->join('labels', 'l.label_id', 'labels.id')
->where('l.service_id', '=', $dn->id) ->where('l.service_id', $dn->id)
->get(['labels.label']); ->get(['labels.label']);
return view('dns.show', compact(['dn', 'dns', 'labels'])); return view('dns.show', compact(['dn', 'dns', 'labels']));
@ -84,8 +84,8 @@ class DNSController extends Controller
$Resellers = Reseller::all(); $Resellers = Reseller::all();
$dn = DNS::findOrFail($dn->id); $dn = DNS::findOrFail($dn->id);
$labels = DB::table('labels_assigned as l') $labels = DB::table('labels_assigned as l')
->join('labels', 'l.label_id', '=', 'labels.id') ->join('labels', 'l.label_id', 'labels.id')
->where('l.service_id', '=', $dn->id) ->where('l.service_id', $dn->id)
->get(['labels.id']); ->get(['labels.id']);
return view('dns.edit', compact(['dn', 'labels', 'Servers', 'Domains', 'Shareds', 'Resellers'])); return view('dns.edit', compact(['dn', 'labels', 'Servers', 'Domains', 'Shareds', 'Resellers']));

View File

@ -43,12 +43,12 @@ class LabelsController extends Controller
public function show(Labels $label) public function show(Labels $label)
{ {
$labels = DB::table('labels_assigned as las') $labels = DB::table('labels_assigned as las')
->leftJoin('pricings as p', 'las.service_id', '=', 'p.service_id') ->leftJoin('pricings as p', 'las.service_id', 'p.service_id')
->leftJoin('servers as s', 'las.service_id', '=', 's.id') ->leftJoin('servers as s', 'las.service_id', 's.id')
->leftJoin('shared_hosting as sh', 'las.service_id', '=', 'sh.id') ->leftJoin('shared_hosting as sh', 'las.service_id', 'sh.id')
->leftJoin('reseller_hosting as r', 'las.service_id', '=', 'r.id') ->leftJoin('reseller_hosting as r', 'las.service_id', 'r.id')
->leftJoin('domains as d', 'las.service_id', '=', 'd.id') ->leftJoin('domains as d', 'las.service_id', 'd.id')
->where('las.label_id', '=', $label->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']); ->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'])); return view('labels.show', compact(['label', 'labels']));

View File

@ -40,17 +40,17 @@ class LocationsController extends Controller
public function show(Locations $location) public function show(Locations $location)
{ {
$servers = DB::table('servers as s') $servers = DB::table('servers as s')
->where('s.location_id', '=', $location->id) ->where('s.location_id', $location->id)
->get(['s.id', 's.hostname']) ->get(['s.id', 's.hostname'])
->toArray(); ->toArray();
$shared = DB::table('shared_hosting as s') $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']) ->get(['s.id', 's.main_domain as main_domain_shared'])
->toArray(); ->toArray();
$reseller = DB::table('reseller_hosting as r') $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']) ->get(['r.id', 'r.main_domain as main_domain_reseller'])
->toArray(); ->toArray();

View File

@ -29,7 +29,7 @@ class Home extends Model
return DB::table('pricings') return DB::table('pricings')
->select('service_type', DB::raw('COUNT(*) as amount')) ->select('service_type', DB::raw('COUNT(*) as amount'))
->groupBy('service_type') ->groupBy('service_type')
->where('active', '=', 1) ->where('active', 1)
->get(); ->get();
}); });
} }
@ -38,13 +38,13 @@ class Home extends Model
{ {
return Cache::remember('due_soon', now()->addHours(6), function () { return Cache::remember('due_soon', now()->addHours(6), function () {
return DB::table('pricings as p') return DB::table('pricings as p')
->leftJoin('servers as s', 'p.service_id', '=', 's.id') ->leftJoin('servers as s', 'p.service_id', 's.id')
->leftJoin('shared_hosting as sh', 'p.service_id', '=', 'sh.id') ->leftJoin('shared_hosting as sh', 'p.service_id', 'sh.id')
->leftJoin('reseller_hosting as r', 'p.service_id', '=', 'r.id') ->leftJoin('reseller_hosting as r', 'p.service_id', 'r.id')
->leftJoin('domains as d', 'p.service_id', '=', 'd.id') ->leftJoin('domains as d', 'p.service_id', 'd.id')
->leftJoin('misc_services as ms', 'p.service_id', '=', 'ms.id') ->leftJoin('misc_services as ms', 'p.service_id', 'ms.id')
->leftJoin('seedboxes as sb', 'p.service_id', '=', 'sb.id') ->leftJoin('seedboxes as sb', 'p.service_id', 'sb.id')
->where('p.active', '=', 1) ->where('p.active', 1)
->orderBy('next_due_date', 'ASC') ->orderBy('next_due_date', 'ASC')
->limit(Session::get('due_soon_amount')) ->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']); ->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() public static function serverSummary()
{ {
return Cache::remember('servers_summary', now()->addHours(6), function () { return Cache::remember('servers_summary', now()->addHours(6), function () {
$cpu_sum = DB::table('servers')->get()->where('active', '=', 1)->sum('cpu'); $cpu_sum = DB::table('servers')->get()->where('active', 1)->sum('cpu');
$ram_mb = DB::table('servers')->get()->where('active', '=', 1)->sum('ram_as_mb'); $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'); $disk_gb = DB::table('servers')->get()->where('active', 1)->sum('disk_as_gb');
$bandwidth = DB::table('servers')->get()->where('active', '=', 1)->sum('bandwidth'); $bandwidth = DB::table('servers')->get()->where('active', 1)->sum('bandwidth');
$locations_sum = DB::table('servers')->get()->where('active', '=', 1)->groupBy('location_id')->count(); $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(); $providers_sum = DB::table('servers')->get()->where('active', 1)->groupBy('provider_id')->count();
return array( return array(
'cpu_sum' => $cpu_sum, 'cpu_sum' => $cpu_sum,
'ram_mb_sum' => $ram_mb, 'ram_mb_sum' => $ram_mb,
@ -75,13 +75,13 @@ class Home extends Model
{ {
return Cache::remember('recently_added', now()->addHours(6), function () { return Cache::remember('recently_added', now()->addHours(6), function () {
return DB::table('pricings as p') return DB::table('pricings as p')
->leftJoin('servers as s', 'p.service_id', '=', 's.id') ->leftJoin('servers as s', 'p.service_id', 's.id')
->leftJoin('shared_hosting as sh', 'p.service_id', '=', 'sh.id') ->leftJoin('shared_hosting as sh', 'p.service_id', 'sh.id')
->leftJoin('reseller_hosting as r', 'p.service_id', '=', 'r.id') ->leftJoin('reseller_hosting as r', 'p.service_id', 'r.id')
->leftJoin('domains as d', 'p.service_id', '=', 'd.id') ->leftJoin('domains as d', 'p.service_id', 'd.id')
->leftJoin('misc_services as ms', 'p.service_id', '=', 'ms.id') ->leftJoin('misc_services as ms', 'p.service_id', 'ms.id')
->leftJoin('seedboxes as sb', 'p.service_id', '=', 'sb.id') ->leftJoin('seedboxes as sb', 'p.service_id', 'sb.id')
->where('p.active', '=', 1) ->where('p.active', 1)
->orderBy('created_at', 'DESC') ->orderBy('created_at', 'DESC')
->limit(Session::get('recently_added_amount')) ->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']); ->get(['p.*', 's.hostname', 'd.domain', 'd.extension', 'r.main_domain as reseller', 'sh.main_domain', 'ms.name', 'sb.title']);

View File

@ -22,7 +22,7 @@ class IPs extends Model
public static function deleteIPsAssignedTo($service_id) 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 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 Cache::remember("ip_addresses.$server_id", now()->addHours(1), function () use ($server_id) {
return json_decode(DB::table('ips as i') return json_decode(DB::table('ips as i')
->where('i.service_id', '=', $server_id) ->where('i.service_id', $server_id)
->get(), true); ->get(), true);
}); });
} }

View File

@ -21,12 +21,12 @@ class Labels extends Model
public static function deleteLabelsAssignedTo($service_id) 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) 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) public static function insertLabelsAssigned(array $labels_array, string $service_id)

View File

@ -106,7 +106,7 @@ class Pricing extends Model
public function deletePricing($id): void 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 public function insertPricing(int $type, string $service_id, string $currency, float $price, int $term, string $next_due_date, int $is_active = 1): Pricing

View File

@ -27,17 +27,17 @@ class Providers extends Model
public static function showServicesForProvider($provider): array public static function showServicesForProvider($provider): array
{ {
$servers = DB::table('servers as s') $servers = DB::table('servers as s')
->where('s.provider_id', '=', $provider) ->where('s.provider_id', $provider)
->get(['s.id', 's.hostname']) ->get(['s.id', 's.hostname'])
->toArray(); ->toArray();
$shared = DB::table('shared_hosting as s') $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']) ->get(['s.id', 's.main_domain as main_domain_shared'])
->toArray(); ->toArray();
$reseller = DB::table('reseller_hosting as r') $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']) ->get(['r.id', 'r.main_domain as main_domain_reseller'])
->toArray(); ->toArray();

View File

@ -63,7 +63,7 @@ class Server extends Model
public static function allActiveServers() public static function allActiveServers()
{//All ACTIVE servers and relationships replaces activeServersDataIndexPage() {//All ACTIVE servers and relationships replaces activeServersDataIndexPage()
return Cache::remember("all_active_servers", now()->addMonth(1), function () { 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']); ->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)) { if (in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$options = Settings::orderByProcess(Session::get('sort_on')); $options = Settings::orderByProcess(Session::get('sort_on'));
@ -76,7 +76,7 @@ class Server extends Model
public static function allNonActiveServers() public static function allNonActiveServers()
{//All NON ACTIVE servers and relationships replaces nonActiveServersDataIndexPage() {//All NON ACTIVE servers and relationships replaces nonActiveServersDataIndexPage()
return Cache::remember("non_active_servers", now()->addMonth(1), function () { 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']) ->with(['location', 'provider', 'os', 'price', 'ips', 'yabs', 'yabs.disk_speed', 'yabs.network_speed', 'labels'])
->get(); ->get();
}); });
@ -85,7 +85,7 @@ class Server extends Model
public static function allPublicServers() public static function allPublicServers()
{//server data that will be publicly viewable (values in settings) {//server data that will be publicly viewable (values in settings)
return Cache::remember("public_server_data", now()->addMonth(1), function () { 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']) ->with(['location', 'provider', 'os', 'price', 'ips', 'yabs', 'yabs.disk_speed', 'yabs.network_speed', 'labels'])
->get(); ->get();
}); });