refactor: replace 'where' with 'whereNull' for clarity in PurchaseItem queries

This commit is contained in:
Yoga Pangestu 2026-04-22 13:49:58 +07:00
parent 481ec6a3f6
commit a121e7b52d
3 changed files with 4 additions and 5 deletions

View File

@ -14,7 +14,7 @@ public function addToCart(AddToCartRequest $request): RedirectResponse
$validated = $request->validated(); $validated = $request->validated();
$item = PurchaseItem::where('user_id', auth()->id()) $item = PurchaseItem::where('user_id', auth()->id())
->where('purchase_id', null) ->whereNull('purchase_id')
->where('product_id', $validated['product_id']) ->where('product_id', $validated['product_id'])
->first(); ->first();

View File

@ -28,7 +28,7 @@ public function create(): Response
'products' => Product::with(['prices', 'categories'])->active()->get(), 'products' => Product::with(['prices', 'categories'])->active()->get(),
'cartItems' => PurchaseItem::with(['product.prices', 'product.categories']) 'cartItems' => PurchaseItem::with(['product.prices', 'product.categories'])
->where('user_id', auth()->id()) ->where('user_id', auth()->id())
->where('purchase_id', null) ->whereNull('purchase_id')
->latest() ->latest()
->get(), ->get(),
]); ]);
@ -61,7 +61,7 @@ public function store(PurchaseRequest $request): RedirectResponse
} }
PurchaseItem::where('user_id', auth()->id()) PurchaseItem::where('user_id', auth()->id())
->where('purchase_id', null) ->whereNull('purchase_id')
->delete(); ->delete();
}); });

View File

@ -782,7 +782,6 @@ export default function PurchaseEdit({ purchase, products }: { purchase: Purchas
</div> </div>
</div> </div>
</div> </div>
{/* Quantity Input Dialog */} {/* Quantity Input Dialog */}
<Dialog open={qtyDialogIndex !== null} onOpenChange={(open) => { if (!open) setQtyDialogIndex(null); }}> <Dialog open={qtyDialogIndex !== null} onOpenChange={(open) => { if (!open) setQtyDialogIndex(null); }}>
<DialogContent className="max-w-xs"> <DialogContent className="max-w-xs">
@ -799,7 +798,7 @@ export default function PurchaseEdit({ purchase, products }: { purchase: Purchas
value={qtyInputValue} value={qtyInputValue}
onChange={e => setQtyInputValue(e.target.value)} onChange={e => setQtyInputValue(e.target.value)}
onKeyDown={e => { if (e.key === 'Enter') confirmQty(); }} onKeyDown={e => { if (e.key === 'Enter') confirmQty(); }}
className="text-center text-lg font-bold" className="text-lg font-bold"
autoFocus autoFocus
/> />
</div> </div>