<?php

use App\Http\Controllers\AccueilController;
use App\Http\Controllers\AnnonceController;
use App\Http\Controllers\ArticleController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\SitemapController;

Route::get('/sitemap.xml', [SitemapController::class, 'index'])->name('sitemap');

Route::get('/', [AccueilController::class, 'index'])->name('accueil');
Route::view('/nos-services', 'public.services')->name('services');

Route::get('/annonces', [AnnonceController::class, 'index'])->name('annonces.index');
Route::get('/liv509', [AnnonceController::class, 'liv509'])->name('liv509');
Route::get('/annonces/{annonce}', [AnnonceController::class, 'show'])->name('annonce.show');
Route::post('/annonces/{annonce}/like', [AnnonceController::class, 'like'])->name('annonce.like');

Route::get('/actualites', [ArticleController::class, 'index'])->name('articles.index');
Route::get('/actualites/{article}', [ArticleController::class, 'show'])->name('article.show');

Route::view('/contact', 'public.contact')->name('contact');

Route::view('/mentions-legales', 'public.legal')->name('legal');

Route::get('/langue/{locale}', function (string $locale) {
    if (in_array($locale, ['fr', 'en', 'ht'])) {
        session(['locale' => $locale]);
    }
    return redirect()->back();
})->name('langue');