Files
brian d9cb44e93c
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled
adding a cart
2026-04-10 08:54:20 -06:00

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';