<?php

use App\Http\Controllers\Installer\DatabaseController;
use App\Http\Controllers\Installer\InstallationController;
use App\Http\Controllers\Installer\LicenseController;
use App\Http\Controllers\Installer\RequirementsController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Installer Routes
|--------------------------------------------------------------------------
|
| These routes are only accessible when the application is not installed.
| They are protected by the CheckInstalled middleware.
|
*/

Route::middleware(['web', 'installer.check'])->prefix('install')->name('installer.')->group(function () {
    // Step 1: Requirements Check
    Route::get('/', [RequirementsController::class, 'index'])->name('step1');

    // Step 2: Database Configuration
    Route::get('/database', [DatabaseController::class, 'index'])->name('step2');
    Route::post('/database/test', [DatabaseController::class, 'testConnection'])->name('database.test');
    Route::post('/database/save', [DatabaseController::class, 'save'])->name('database.save');

    // Step 3: License Activation
    Route::get('/license', [LicenseController::class, 'index'])->name('step3');
    Route::post('/license/verify', [LicenseController::class, 'verify'])->name('license.verify');

    // Step 4: Demo Data & Installation
    Route::get('/demo-data', [InstallationController::class, 'index'])->name('step4');
    Route::post('/complete', [InstallationController::class, 'complete'])->name('complete');

    // Success Page
    Route::get('/success', [InstallationController::class, 'success'])->name('success');
});
