removed setup controller

This commit is contained in:
2024-10-04 19:14:26 +03:00
parent 55db377abf
commit 174a119c2e
17 changed files with 61 additions and 447 deletions
-72
View File
@@ -1,72 +0,0 @@
<?php
namespace Lucent\Http\Controller;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Lucent\Account\AccountService;
use Lucent\Channel\ChannelService;
use Lucent\LucentException;
use Lucent\Setup\Data\SetupStep;
use Lucent\Setup\Data\SetupStepStatus;
use Lucent\Setup\Setup;
use Lucent\Setup\Step\ComposerStep;
use Lucent\Setup\Step\DatabaseSetupStep;
use Lucent\Setup\Step\IStep;
use Lucent\Setup\Step\LaravelEnvStep;
use Lucent\Setup\Step\LucentConfigStep;
use Lucent\Setup\Step\StorageLinkSetupStep;
use Lucent\Setup\Step\StorageSetupStep;
use Lucent\Svelte\Svelte;
use function Lucent\Response\fail;
use function Lucent\Response\ok;
class SetupController
{
public function __construct(
private readonly AccountService $accountService,
private readonly ChannelService $channelService,
private readonly Svelte $svelte,
)
{
}
public function setup(Request $request): View|RedirectResponse
{
$steps = array_reduce([
new ComposerStep,
new LucentConfigStep,
new LaravelEnvStep,
new StorageSetupStep,
new StorageLinkSetupStep,
new DatabaseSetupStep,
], fn(array $carry, IStep $setupStep) => array_merge($carry, [$setupStep()]), []);
$allSuccess = array_reduce($steps, fn(bool $carry, SetupStep $step) => !$carry ? false : $step->status === SetupStepStatus::SUCCESS, true);
if($allSuccess){
if ($this->accountService->countUsers() > 0) {
return redirect($this->channelService->channel->lucentUrl . "/login");
}
}
return $this->svelte->render(
layout: "account",
view: "setup",
title: "Setup Lucent",
data: [
"steps" => $steps,
"allSuccess" => $allSuccess,
]
);
}
}
-4
View File
@@ -10,10 +10,8 @@ use Lucent\Http\Controller\HomeController;
use Lucent\Http\Controller\MemberController;
use Lucent\Http\Controller\RecordController;
use Lucent\Http\Controller\RevisionController;
use Lucent\Http\Controller\SetupController;
Route::get('/lucent/setup', [SetupController::class, 'setup']);
Route::get('/lfs-{disk}/{any}', [FileController::class, 'fromDisk'])->where('any', '.*');
@@ -23,7 +21,6 @@ Route::group([
], function () {
Route::middleware(['lucent.guest'])->group(function () {
Route::get('/', [AuthController::class, 'login']);
@@ -95,6 +92,5 @@ Route::group([
});
});