<?php

use App\Http\Controllers\Web\AuthController;
use App\Http\Controllers\Web\DashboardController;
use App\Http\Controllers\Web\PontoTuristicoController;
use App\Http\Controllers\Web\PublicPontoTuristicoController;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return view('welcome');
})->name('home');

Route::get('/pontos-turisticos', [PublicPontoTuristicoController::class, 'index'])->name('pontos-turisticos.index');
Route::get('/pontos-turisticos/{ponto}', [PublicPontoTuristicoController::class, 'show'])->name('pontos-turisticos.show');

Route::middleware('guest')->group(function () {
    Route::get('/login', [AuthController::class, 'showLoginForm'])->name('login');
    Route::post('/login', [AuthController::class, 'login']);
    Route::get('/register', [AuthController::class, 'showRegisterForm'])->name('register');
    Route::post('/register', [AuthController::class, 'register']);
});

Route::middleware('auth')->group(function () {
    Route::post('/logout', [AuthController::class, 'logout'])->name('logout');
    Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
});

Route::middleware(['auth', 'admin.access'])->prefix('admin')->name('admin.')->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'adminDashboard'])->name('dashboard');
    Route::get('/pontos-turisticos', [PontoTuristicoController::class, 'index'])->name('pontos-turisticos.index');
    Route::get('/pontos-turisticos/create', [PontoTuristicoController::class, 'create'])->name('pontos-turisticos.create');
    Route::post('/pontos-turisticos', [PontoTuristicoController::class, 'store'])->name('pontos-turisticos.store');
    Route::get('/pontos-turisticos/{ponto}', [PontoTuristicoController::class, 'show'])->name('pontos-turisticos.show');
    Route::get('/pontos-turisticos/{ponto}/edit', [PontoTuristicoController::class, 'edit'])->name('pontos-turisticos.edit');
    Route::put('/pontos-turisticos/{ponto}', [PontoTuristicoController::class, 'update'])->name('pontos-turisticos.update');
    Route::delete('/pontos-turisticos/{ponto}', [PontoTuristicoController::class, 'destroy'])->name('pontos-turisticos.destroy');
});
