<?php

use App\Http\Controllers\AdminBackgroundGenerationController;
use App\Http\Controllers\AdminDashboardController;
use App\Http\Controllers\FrontHomeController;
use App\Http\Controllers\UserDashboardController;
use App\Http\Middleware\AdminMiddleware;
use Illuminate\Support\Facades\Route;

if (App::environment('local')) {

    Route::middleware(['auth', 'verified'])->group(function () {

        Route::get('dashboard', [UserDashboardController::class, 'index'])->name('dashboard');

        Route::prefix('admin')->middleware([AdminMiddleware::class])->group(function () {
            Route::get('/', [AdminDashboardController::class, 'index'])->name('admin.dashboard');

            Route::prefix('background-generation')->group(function () {
                Route::get('/', [AdminBackgroundGenerationController::class, 'index'])->name('admin.background-generation');

                Route::post('generate', [AdminBackgroundGenerationController::class, 'generate'])
                    ->name('admin.background-generation.generate');

                Route::post('save', [AdminBackgroundGenerationController::class, 'save'])
                    ->name('admin.background-generation.save');

                Route::post('delete/{id}', [AdminBackgroundGenerationController::class, 'delete'])
                    ->name('admin.background-generation.delete');
            });
        });
    });

    require __DIR__.'/settings.php';
    require __DIR__.'/auth.php';
}

Route::get('/', [FrontHomeController::class, 'index'])->name('home')->middleware('cacheResponse:3600');
