32 lines
830 B
PHP
32 lines
830 B
PHP
<?php
|
|
|
|
use App\Models\Cart;
|
|
use App\Models\Product;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Laravel\Fortify\Features;
|
|
|
|
/*Route::inertia('/', 'Welcome', [
|
|
'canRegister' => Features::enabled(Features::registration()),
|
|
])->name('home');*/
|
|
|
|
Route::get('/', function () {
|
|
$cartId = session('cart_id');
|
|
$cart = $cartId ? Cart::with('products')->find($cartId) : null;
|
|
|
|
return inertia('Home', [
|
|
'products' => Product::all(),
|
|
'cart' => $cart
|
|
? $cart->products->map(fn ($p) => [
|
|
'product_id' => $p->id,
|
|
'quantity' => $p->pivot->quantity,
|
|
])
|
|
: [],
|
|
]);
|
|
})->name('home');
|
|
|
|
Route::middleware(['auth', 'verified'])->group(function () {
|
|
Route::inertia('dashboard', 'Dashboard')->name('dashboard');
|
|
});
|
|
|
|
require __DIR__.'/settings.php';
|