<?php

use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\ContactController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\Dashboard\ContactController as DashboardContactController;
use App\Http\Controllers\Dashboard\DeviController;
use App\Http\Controllers\Dashboard\RealisationController;
use App\Http\Controllers\DevisController;
use App\Http\Controllers\PageController;
use Illuminate\Support\Facades\Route;

// Pages publiques
Route::get('/', [PageController::class, 'accueil'])->name('accueil');
Route::get('/services', [PageController::class, 'services'])->name('services');
Route::get('/a-propos', [PageController::class, 'apropos'])->name('apropos');
Route::get('/realisations', [PageController::class, 'realisations'])->name('realisations');
Route::get('/contact', [PageController::class, 'contact'])->name('contact');
Route::get('/devis', [PageController::class, 'devis'])->name('devis');

Route::post('/contact', [ContactController::class, 'store'])->name('contact.store');
Route::post('/devis', [DevisController::class, 'store'])->name('devis.store');

// Authentification
Route::get('/login', [LoginController::class, 'showLoginForm'])->name('login')->middleware('guest');
Route::post('/login', [LoginController::class, 'login']);
Route::post('/logout', [LoginController::class, 'logout'])->name('logout');

// Dashboard (protégé)
Route::middleware('auth')->prefix('dashboard')->name('dashboard.')->group(function () {
    Route::get('/', [DashboardController::class, 'index'])->name('index');
    Route::resource('realisations', RealisationController::class);
    Route::resource('contacts', DashboardContactController::class)->only(['index', 'show', 'destroy']);
    Route::resource('devis', DeviController::class)->only(['index', 'show', 'update', 'destroy']);
});
