41 lines
1.8 KiB
PHP
41 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Enums\ServiceStatus;
|
|
use App\Models\Operation;
|
|
use App\Models\Organisation;
|
|
use App\Models\Provider;
|
|
use App\Models\Service;
|
|
use Illuminate\Http\Request;
|
|
use Inertia\Inertia;
|
|
|
|
class OrganisationController extends Controller
|
|
{
|
|
public function show(Request $request)
|
|
{
|
|
return inertia('organisations/Show', [
|
|
'providers' => Inertia::lazy(fn () => Provider::whereOrganisationId($request->route('organisation'))->get()),
|
|
'registries' => Inertia::lazy(fn () => Organisation::findOrFail($request->route('organisation'))->registries()->get()),
|
|
'sourceProviders' => Inertia::lazy(fn () => Organisation::findOrFail($request->route('organisation'))->sourceProviders()->get()),
|
|
'organisation' => Organisation::with('members')
|
|
->withCount('servers', 'applications', 'members', 'providers', 'sourceProviders', 'registries')
|
|
->findOrFail($request->route('organisation')),
|
|
'health' => [
|
|
'unhealthy_services' => Service::query()
|
|
->where('organisation_id', $request->route('organisation'))
|
|
->whereNot('status', ServiceStatus::RUNNING)
|
|
->count(),
|
|
'failed_operations' => Operation::query()
|
|
->whereHasMorph('target', [Service::class], fn ($query) => $query->where('organisation_id', $request->route('organisation')))
|
|
->where('status', 'failed')
|
|
->count(),
|
|
'locked_variables' => Organisation::findOrFail($request->route('organisation'))
|
|
->applications()
|
|
->whereHas('environments.variables', fn ($query) => $query->where('overridable', false))
|
|
->count(),
|
|
],
|
|
]);
|
|
}
|
|
}
|