<?php

use App\Http\Controllers\Site\CareersController;
use App\Http\Controllers\Site\ContactController;
use App\Http\Controllers\Site\ContentPageController;
use App\Http\Controllers\Site\DownloadsController;
use App\Http\Controllers\Site\HomeController;
use App\Http\Controllers\Site\NewsController;
use App\Http\Controllers\Site\ReferralController;
use App\Http\Controllers\Site\RobotsController;
use App\Http\Controllers\Site\ServiceListingController;
use App\Http\Controllers\Site\SitemapController;
use Illuminate\Support\Facades\Route;

Route::get('/', HomeController::class)->name('home');
Route::get('/how-it-works', function () { return view('site.how-it-works'); })->name('how-it-works');

Route::get('/services', [ServiceListingController::class, 'index'])->name('services.index');

Route::get('/news', [NewsController::class, 'index'])->name('news.index');
Route::get('/news/{post:slug}', [NewsController::class, 'show'])->name('news.show');
Route::redirect('/gallery', '/testimonials')->name('gallery');

Route::get('/careers', [CareersController::class, 'index'])->name('careers.index');
Route::get('/careers/{job:slug}', [CareersController::class, 'show'])->name('careers.show');
Route::post('/careers/{job:slug}/apply', [CareersController::class, 'apply'])
    ->middleware(['honeypot', 'throttle:forms'])
    ->name('careers.apply');

Route::get('/downloads', [DownloadsController::class, 'index'])->name('downloads.index');
Route::get('/downloads/{download:slug}', [DownloadsController::class, 'file'])->name('downloads.file');

Route::get('/contact', [ContactController::class, 'show'])->name('contact.show');
Route::post('/contact', [ContactController::class, 'store'])
    ->middleware(['honeypot', 'throttle:forms'])
    ->name('contact.store');

Route::get('/referral', [ReferralController::class, 'show'])->name('referral.show');
Route::post('/referral', [ReferralController::class, 'store'])
    ->middleware(['honeypot', 'throttle:forms'])
    ->name('referral.store');

Route::get('/sitemap.xml', SitemapController::class)->name('sitemap');
Route::get('/robots.txt', RobotsController::class)->name('robots');

Route::get('/{slug}', [ContentPageController::class, 'show'])
    ->whereIn('slug', ['about', 'who-we-support', 'testimonials', 'privacy']);

Route::fallback(function () {
    return response()->view('errors.404', [], 404);
});
