adding a cart
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

This commit is contained in:
2026-04-10 08:54:20 -06:00
parent ebf30d4f5f
commit d9cb44e93c
16 changed files with 559 additions and 39 deletions
+15 -3
View File
@@ -1,5 +1,6 @@
<?php
use App\Models\Cart;
use App\Models\Product;
use Illuminate\Support\Facades\Route;
use Laravel\Fortify\Features;
@@ -8,9 +9,20 @@ use Laravel\Fortify\Features;
'canRegister' => Features::enabled(Features::registration()),
])->name('home');*/
Route::get('/', fn () => inertia('Home', [
'products' => Product::all(),
]))->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');