44 lines
1.1 KiB
PHP
Raw Normal View History

2023-03-17 15:33:48 +01:00
<?php
namespace App\Http\Controllers;
2023-06-07 15:08:35 +02:00
use App\Models\InstanceSettings;
use App\Models\Project;
use App\Models\Server;
2023-03-17 15:33:48 +01:00
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, ValidatesRequests;
2023-06-07 15:08:35 +02:00
public function dashboard()
{
$projects = Project::ownedByCurrentTeam()->get();
$servers = Server::ownedByCurrentTeam()->get();
$resources = 0;
foreach ($projects as $project) {
$resources += $project->applications->count();
}
return view('dashboard', [
'servers' => $servers->count(),
'projects' => $projects->count(),
'resources' => $resources,
]);
}
public function settings()
{
if (auth()->user()->isAdmin()) {
$settings = InstanceSettings::get();
return view('settings', [
'settings' => $settings
]);
} else {
return redirect()->route('dashboard');
}
}
2023-03-17 15:33:48 +01:00
}