Files
jouwdriedee/routes/web.php
T

88 lines
4.0 KiB
PHP

<?php
use App\Http\Controllers\Admin\MakerWorldController;
use App\Http\Controllers\CartController;
use App\Http\Controllers\CheckoutController;
use App\Http\Controllers\ShopController;
use App\Models\Category;
use App\Models\Product;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Schema;
// Health & Diagnostics
Route::get('/health-debug', function () {
$dbPath = config('database.connections.sqlite.database');
$diagnostics = [
'php_version' => PHP_VERSION,
'app_env' => config('app.env'),
'has_app_key' => ! empty(config('app.key')),
'app_key_len' => strlen((string) config('app.key')),
'db_connection' => config('database.default'),
'db_path' => $dbPath,
'db_file_exists' => is_string($dbPath) && file_exists($dbPath),
'db_dir_writable' => is_string($dbPath) && is_writable(dirname($dbPath)),
];
try {
DB::connection()->getPdo();
$diagnostics['db_pdo'] = 'CONNECTED';
$diagnostics['tables'] = Schema::getTableListing();
} catch (Throwable $e) {
$diagnostics['db_pdo_error'] = $e->getMessage();
}
try {
$diagnostics['categories_count'] = Category::count();
} catch (Throwable $e) {
$diagnostics['categories_error'] = $e->getMessage();
}
try {
$diagnostics['products_count'] = Product::count();
} catch (Throwable $e) {
$diagnostics['products_error'] = $e->getMessage();
}
return response()->json($diagnostics);
})->withoutMiddleware([
StartSession::class,
EncryptCookies::class,
]);
// Shop & Product routes
Route::get('/', [ShopController::class, 'index'])->name('home');
Route::get('/catalogus', [ShopController::class, 'catalog'])->name('catalog');
Route::get('/product/{slug}', [ShopController::class, 'show'])->name('product.show');
Route::get('/custom-3d-print', [ShopController::class, 'customRequest'])->name('custom.request');
Route::post('/custom-3d-print', [ShopController::class, 'storeCustomRequest'])->name('custom.store');
Route::post('/custom-3d-print/bestellen', [CartController::class, 'addCustom'])->name('custom.cart.add');
// Winkelwagen
Route::get('/winkelwagen', [CartController::class, 'index'])->name('cart.index');
Route::post('/winkelwagen/toevoegen', [CartController::class, 'add'])->name('cart.add');
Route::post('/winkelwagen/bijwerken', [CartController::class, 'update'])->name('cart.update');
Route::delete('/winkelwagen/verwijderen/{key}', [CartController::class, 'remove'])->name('cart.remove');
Route::get('/winkelwagen/aantal', [CartController::class, 'count'])->name('cart.count');
// Afrekenen & Bevestiging
Route::get('/afrekenen', [CheckoutController::class, 'index'])->name('checkout.index');
Route::post('/afrekenen', [CheckoutController::class, 'store'])->name('checkout.store');
Route::get('/bestelling-ontvangen/{orderNumber}', [CheckoutController::class, 'success'])->name('checkout.success');
// Admin & MakerWorld Beheer
Route::prefix('admin')->name('admin.')->group(function () {
Route::redirect('/', '/admin/makerworld');
Route::get('/makerworld', [MakerWorldController::class, 'index'])->name('makerworld.index');
Route::post('/makerworld/login', [MakerWorldController::class, 'login'])->name('makerworld.login');
Route::post('/makerworld/verify-code', [MakerWorldController::class, 'verifyCode'])->name('makerworld.verify-code');
Route::post('/makerworld/token', [MakerWorldController::class, 'saveToken'])->name('makerworld.token');
Route::post('/makerworld/disconnect', [MakerWorldController::class, 'disconnect'])->name('makerworld.disconnect');
Route::get('/makerworld/preview', [MakerWorldController::class, 'preview'])->name('makerworld.preview');
Route::post('/makerworld/import', [MakerWorldController::class, 'import'])->name('makerworld.import');
Route::post('/makerworld/batch-import', [MakerWorldController::class, 'batchImport'])->name('makerworld.batch-import');
});