mirror of
https://github.com/cp6/my-idlers.git
synced 2024-11-16 15:33:44 +01:00
Cleaned up queries that had un-needed '='
This commit is contained in:
parent
877592f614
commit
afe5c1e525
@ -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);
|
||||
}
|
||||
|
@ -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']));
|
||||
|
@ -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']));
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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']);
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user