2022-03-05 16:02:12 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2022-05-14 17:22:47 +02:00
|
|
|
use App\Models\DNS;
|
2022-05-16 06:42:48 +02:00
|
|
|
use App\Models\Home;
|
2022-05-14 17:22:47 +02:00
|
|
|
use App\Models\Labels;
|
2022-03-05 16:02:12 +01:00
|
|
|
use App\Models\Pricing;
|
2022-05-16 07:43:51 +02:00
|
|
|
use App\Models\Settings;
|
2022-03-05 16:02:12 +01:00
|
|
|
use Carbon\Carbon;
|
2022-03-05 16:58:25 +01:00
|
|
|
use Illuminate\Support\Facades\Cache;
|
2022-03-05 16:02:12 +01:00
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use App\Process;
|
|
|
|
use Illuminate\Support\Facades\Session;
|
|
|
|
|
|
|
|
|
|
|
|
class HomeController extends Controller
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->middleware('auth');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$p = new Process();
|
|
|
|
$p->startTimer();
|
|
|
|
|
2022-05-16 08:22:19 +02:00
|
|
|
//Get & set the settings, 1 minute cache
|
2022-05-16 07:43:51 +02:00
|
|
|
$settings = Settings::getSettings();
|
|
|
|
Settings::setSettingsToSession($settings);
|
2022-03-05 16:02:12 +01:00
|
|
|
|
2022-05-16 08:22:19 +02:00
|
|
|
//Check for past due date and refresh the due date if so:
|
|
|
|
$due_soon = Home::doDueSoon(Home::dueSoonData());
|
2022-05-16 07:43:51 +02:00
|
|
|
|
2022-05-16 08:22:19 +02:00
|
|
|
//Orders services most recently added first, cached with limit from settings
|
|
|
|
$recently_added = Home::recentlyAdded();
|
2022-03-05 16:02:12 +01:00
|
|
|
|
2022-05-16 08:22:19 +02:00
|
|
|
//Get count tally for each of the services type
|
|
|
|
$service_count = Home::doServicesCount(Home::servicesCount());
|
2022-03-05 16:02:12 +01:00
|
|
|
|
2022-05-16 08:22:19 +02:00
|
|
|
//Get pricing for weekly, monthly, yearly, 2 yearly
|
|
|
|
$pricing_breakdown = Home::breakdownPricing(Pricing::allPricing());
|
2022-03-05 16:02:12 +01:00
|
|
|
|
2022-05-16 08:22:19 +02:00
|
|
|
//Summary of servers specs
|
|
|
|
$server_summary = Home::serverSummary();
|
2022-05-16 06:42:48 +02:00
|
|
|
|
2022-03-05 16:02:12 +01:00
|
|
|
$p->stopTimer();
|
|
|
|
|
2023-03-31 02:38:21 +02:00
|
|
|
$information = [
|
2022-05-16 08:22:19 +02:00
|
|
|
'servers' => $service_count['servers'],
|
|
|
|
'domains' => $service_count['domains'],
|
|
|
|
'shared' => $service_count['shared'],
|
|
|
|
'reseller' => $service_count['reseller'],
|
|
|
|
'misc' => $service_count['other'],
|
|
|
|
'seedbox' => $service_count['seedbox'],
|
2022-05-14 17:22:47 +02:00
|
|
|
'labels' => Labels::labelsCount(),
|
|
|
|
'dns' => DNS::dnsCount(),
|
2022-05-16 08:22:19 +02:00
|
|
|
'total_services' => $service_count['total'],
|
2022-05-16 06:42:48 +02:00
|
|
|
'total_inactive' => $pricing_breakdown['inactive_count'],
|
|
|
|
'total_cost_weekly' => number_format($pricing_breakdown['total_cost_weekly'], 2),
|
|
|
|
'total_cost_monthly' => number_format($pricing_breakdown['total_cost_montly'], 2),
|
|
|
|
'total_cost_yearly' => number_format($pricing_breakdown['total_cost_yearly'], 2),
|
|
|
|
'total_cost_2_yearly' => number_format(($pricing_breakdown['total_cost_yearly'] * 2), 2),
|
2022-03-05 16:02:12 +01:00
|
|
|
'due_soon' => $due_soon,
|
|
|
|
'newest' => $recently_added,
|
2022-03-09 03:18:30 +01:00
|
|
|
'execution_time' => number_format($p->getTimeTaken(), 2),
|
2022-05-29 08:46:55 +02:00
|
|
|
'servers_summary' => $server_summary,
|
|
|
|
'currency' => Session::get('dashboard_currency')
|
2023-03-31 02:38:21 +02:00
|
|
|
];
|
2022-03-05 16:02:12 +01:00
|
|
|
|
|
|
|
return view('home', compact('information'));
|
|
|
|
}
|
|
|
|
}
|