77 lines
2.8 KiB
PHP
77 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Organisation;
|
|
use Inertia\Response;
|
|
|
|
class OnboardingController extends Controller
|
|
{
|
|
public function show(Organisation $organisation): Response
|
|
{
|
|
$organisation->loadCount(['providers', 'sourceProviders', 'registries', 'servers', 'applications']);
|
|
|
|
$applicationNeedingDeployKey = $organisation->applications()
|
|
->whereNull('deploy_key_installed_at')
|
|
->first();
|
|
|
|
$steps = [
|
|
[
|
|
'key' => 'organisation',
|
|
'label' => 'Organisation',
|
|
'complete' => true,
|
|
'href' => route('organisations.show', ['organisation' => $organisation->id]),
|
|
],
|
|
[
|
|
'key' => 'provider',
|
|
'label' => 'Provider',
|
|
'complete' => $organisation->providers_count > 0,
|
|
'href' => route('organisations.show', ['organisation' => $organisation->id]),
|
|
],
|
|
[
|
|
'key' => 'source',
|
|
'label' => 'Source',
|
|
'complete' => $organisation->source_providers_count > 0,
|
|
'href' => route('source-providers.create', ['organisation' => $organisation->id]),
|
|
],
|
|
[
|
|
'key' => 'registry',
|
|
'label' => 'Registry',
|
|
'complete' => $organisation->registries_count > 0,
|
|
'href' => route('registries.create', ['organisation' => $organisation->id]),
|
|
],
|
|
[
|
|
'key' => 'server',
|
|
'label' => 'Server',
|
|
'complete' => $organisation->servers_count > 0,
|
|
'href' => route('servers.create', ['organisation' => $organisation->id]),
|
|
],
|
|
[
|
|
'key' => 'application',
|
|
'label' => 'Application',
|
|
'complete' => $organisation->applications_count > 0,
|
|
'href' => route('applications.create', ['organisation' => $organisation->id]),
|
|
],
|
|
[
|
|
'key' => 'deploy-key',
|
|
'label' => 'Deploy key',
|
|
'complete' => $organisation->applications_count === 0 || $applicationNeedingDeployKey === null,
|
|
'href' => $applicationNeedingDeployKey
|
|
? route('applications.show', [
|
|
'organisation' => $organisation->id,
|
|
'application' => $applicationNeedingDeployKey->id,
|
|
])
|
|
: route('applications.index', ['organisation' => $organisation->id]),
|
|
],
|
|
];
|
|
|
|
$next = collect($steps)->firstWhere('complete', false) ?? $steps[array_key_last($steps)];
|
|
|
|
return inertia('onboarding/Show', [
|
|
'organisation' => $organisation,
|
|
'steps' => $steps,
|
|
'nextStep' => $next,
|
|
]);
|
|
}
|
|
}
|