ldc-boutique-cnc/routes/web-fo.php
2023-05-23 09:32:54 +02:00

102 lines
4.3 KiB
PHP

<?php
use App\Enums\StaticPageType;
use Illuminate\Support\Facades\Route;
// FRONT.
use App\Http\Controllers\Fo\CustomerController;
use App\Http\Controllers\Fo\StaticPageController;
// AUTH.
use App\Http\Controllers\Fo\ContactController;
use App\Http\Controllers\Fo\ProductController;
use App\Http\Controllers\Fo\RangeController;
use App\Http\Controllers\Fo\TagController;
use App\Models\Site\StaticPage;
use Illuminate\Support\Facades\Auth;
Route::namespace('\App\Http\Controllers\Fo')->middleware(['throttle:credentials'])->group(function () {
Auth::routes([
'login' => true,
'logout' => true,
'register' => true,
// For resetting passwords.
'reset' => true,
// For additional password confirmations.
'confirm' => true,
// For email verification.
'verify' => true,
]);
});
Route::middleware(['auth:frontend', 'verified'])->group(function () {
Route::name('account.')->prefix('compte')->group(function () {
// * User Profile
Route::get('/profil', [CustomerController::class, 'dashboard'])->name('dashboard');
Route::post('/profil', [CustomerController::class, 'updateInfos'])->name('update-infos');
// * Orders
Route::get('/commandes', [CustomerController::class, 'myOrders'])->name('orders');
Route::get('/commandes/{reference}', [CustomerController::class, 'orderDetail'])->name('orders.show');
Route::get(
'/commandes/{reference}/transaction/{transactionReference}/invoice',
[CustomerController::class, 'downloadTransactionInvoice']
)->middleware('throttle:2,1')->name('orders.transaction.invoice');
// * Security
Route::get('/securite/identification/email', [CustomerController::class, 'email'])->name('email');
Route::post('/securite/identification/email', [CustomerController::class, 'emailSubmit'])->name('emailSubmit');
Route::get('/securite/identification/motdepasse', [CustomerController::class, 'password'])->name('password');
Route::post('/securite/identification/motdepasse', [
CustomerController::class, 'passwordSubmit'
])->name('passwordSubmit');
// * Delete account
Route::get('/securite/suppression', [CustomerController::class, 'destroy'])->name('destroy');
Route::post('/securite/suppression', [CustomerController::class, 'destroySubmit'])->name('destroySubmit');
});
});
// * AJAX
Route::prefix('ajax')->name('ajax.')->group(function () {
// * Single optin
Route::post('/optin', [CustomerController::class, 'addOptIn'])->name('add-single-optin');
});
// * STATIC PAGES
// * Contact post page
/** @var \App\Models\StaticPage|null */
if ($contactPage = StaticPage::getCached()->where('type', StaticPageType::contact())->first()) {
Route::post($contactPage->slug, [ContactController::class, 'contactSubmit']);
}
Route::get('/pages', [StaticPageController::class, 'displayCrudStaticPageIndex'])->name('static-page.index');
Route::get('/pages/{static_page_front:slug}', [StaticPageController::class, 'displayCrudStaticPage'])
->name('static-page.view-crud');
// * Home static Page
Route::get('/', [StaticPageController::class, 'home'])->name('home');
// * Search
Route::get('/recherche', [ProductController::class, 'searchProducts'])->name('search');
// * Catalogue.
// * Ranges
Route::get('/gammes-de-produits', [RangeController::class, 'ranges'])->name('ranges.index');
Route::get('/gamme-de-produits/{rangeSlug}', [RangeController::class, 'range'])
->middleware('redirect-slugs')->name('ranges.show');
Route::get('/gammes-de-produits/card/{rangeSlug}', [RangeController::class, 'ajaxRangesCard'])->name('ranges.card');
// * Products
Route::get('/produits', [ProductController::class, 'products'])->name('products.index');
Route::get('/produit/{productSlug}', [ProductController::class, 'product'])
->middleware('redirect-slugs')->name('products.show');
Route::get('/produits/card/{productSlug}', [ProductController::class, 'ajaxProductsCard'])->name('products.card');
// * - Tags
Route::get('/produits/special', [TagController::class, 'tags'])->name('tags.index');
Route::get('/produits/{tagSlug}', [TagController::class, 'tag'])->name('tags.show');
// * All static pages except crud.
Route::get('/{static_page_front:slug}', [StaticPageController::class, 'displayStaticPage'])
->name('static-page.view');