<?php

use App\Http\Controllers\StorefrontController;
use App\Http\Controllers\ContentPageController;
use App\Http\Controllers\NewsletterController;
use App\Http\Controllers\OrderTrackingController;
use App\Http\Controllers\SitemapController;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;

Route::get('/', [StorefrontController::class, 'index'])->name('storefront.home');
Route::post('/newsletter', [NewsletterController::class, 'store'])->name('newsletter.store');
Route::get('/track-order', OrderTrackingController::class)->name('orders.track');
Route::get('/products/{product:slug}', [StorefrontController::class, 'show'])->name('storefront.products.show');
Route::get('/categories/{category:slug}', [StorefrontController::class, 'category'])->name('storefront.categories.show');
Route::get('/pages/{page:slug}', [ContentPageController::class, 'show'])->name('content-pages.show');
Route::get('/sitemap.xml', SitemapController::class)->name('sitemap');
Route::get('/storage/{path}', function (string $path) {
    abort_if(Str::contains($path, ['..', '\\']) || ! Storage::disk('public')->exists($path), 404);

    return Storage::disk('public')->response($path);
})->where('path', '.*')->name('public-storage.show');

require __DIR__.'/customer.php';
require __DIR__.'/admin.php';
