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 06:42:48 +02:00
|
|
|
$services_count = Home::servicesCount();
|
2022-03-05 16:58:25 +01:00
|
|
|
|
2022-05-16 06:42:48 +02:00
|
|
|
$due_soon = Home::dueSoonData();
|
2022-03-05 16:02:12 +01:00
|
|
|
|
2022-05-16 06:42:48 +02:00
|
|
|
$server_summary = Home::serverSummary();
|
2022-03-05 16:02:12 +01:00
|
|
|
|
|
|
|
//Check for past due date and refresh the due date if so:
|
2022-05-16 06:42:48 +02:00
|
|
|
$due_soon = Home::doDueSoon($due_soon);
|
2022-03-05 16:02:12 +01:00
|
|
|
|
2022-05-16 06:42:48 +02:00
|
|
|
$recently_added = Home::recentlyAdded();
|
2022-03-05 16:58:25 +01:00
|
|
|
|
2022-05-16 07:43:51 +02:00
|
|
|
$settings = Settings::getSettings();
|
2022-03-05 16:02:12 +01:00
|
|
|
|
2022-05-16 07:43:51 +02:00
|
|
|
Settings::setSettingsToSession($settings);
|
2022-03-05 16:02:12 +01:00
|
|
|
|
2022-05-14 17:22:47 +02:00
|
|
|
$all_pricing = Pricing::allPricing();
|
2022-05-16 07:43:51 +02:00
|
|
|
|
2022-03-05 16:02:12 +01:00
|
|
|
$services_count = json_decode($services_count, true);
|
|
|
|
|
2022-05-16 06:42:48 +02:00
|
|
|
$servers_count = $domains_count = $shared_count = $reseller_count = $other_count = $seedbox_count = $total_services = 0;
|
2022-03-05 16:02:12 +01:00
|
|
|
|
|
|
|
foreach ($services_count as $sc) {
|
|
|
|
$total_services += $sc['amount'];
|
|
|
|
if ($sc['service_type'] === 1) {
|
|
|
|
$servers_count = $sc['amount'];
|
|
|
|
} else if ($sc['service_type'] === 2) {
|
|
|
|
$shared_count = $sc['amount'];
|
|
|
|
} else if ($sc['service_type'] === 3) {
|
|
|
|
$reseller_count = $sc['amount'];
|
|
|
|
} else if ($sc['service_type'] === 4) {
|
|
|
|
$domains_count = $sc['amount'];
|
|
|
|
} else if ($sc['service_type'] === 5) {
|
|
|
|
$other_count = $sc['amount'];
|
2022-05-16 06:42:48 +02:00
|
|
|
} else if ($sc['service_type'] === 6) {
|
|
|
|
$seedbox_count = $sc['amount'];
|
2022-03-05 16:02:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-16 06:42:48 +02:00
|
|
|
$pricing_breakdown = Home::breakdownPricing($all_pricing);
|
|
|
|
|
2022-03-05 16:02:12 +01:00
|
|
|
$p->stopTimer();
|
|
|
|
|
|
|
|
$information = array(
|
|
|
|
'servers' => $servers_count,
|
|
|
|
'domains' => $domains_count,
|
|
|
|
'shared' => $shared_count,
|
|
|
|
'reseller' => $reseller_count,
|
|
|
|
'misc' => $other_count,
|
2022-05-16 06:42:48 +02:00
|
|
|
'seedbox' => $seedbox_count,
|
2022-05-14 17:22:47 +02:00
|
|
|
'labels' => Labels::labelsCount(),
|
|
|
|
'dns' => DNS::dnsCount(),
|
2022-03-05 16:02:12 +01:00
|
|
|
'total_services' => $total_services,
|
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),
|
|
|
|
'servers_summary' => $server_summary
|
2022-03-05 16:02:12 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
return view('home', compact('information'));
|
|
|
|
}
|
|
|
|
}
|