From d94a271da02281f2ee7d2d8a628be289b7319204 Mon Sep 17 00:00:00 2001 From: nisrinasalm Date: Tue, 10 Dec 2024 22:21:42 +0700 Subject: [PATCH] feat: show transaction history in admin --- app/Http/Controllers/TransactionController.php | 2 +- resources/js/Layouts/Navbar.tsx | 2 +- resources/js/Pages/Transaction/Index.tsx | 6 ++++++ resources/js/types/entities/cart.ts | 4 ++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index 006ccd8..1db2196 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -19,7 +19,7 @@ public function index(Request $request) $category = Category::all(); - $transaction = Transaction::with(['cart_product.product.category']) + $transaction = Transaction::with(['cart_product.user', 'cart_product.product.category']) ->whereHas('cart_product.product.category', function ($query) use ($categoryIds) { if (!empty($categoryIds)) { $query->whereIn('category_id', $categoryIds); diff --git a/resources/js/Layouts/Navbar.tsx b/resources/js/Layouts/Navbar.tsx index efb0b01..3fa3c7c 100644 --- a/resources/js/Layouts/Navbar.tsx +++ b/resources/js/Layouts/Navbar.tsx @@ -48,7 +48,7 @@ export default function Navbar() { Cart )}{" "} - {auth.user !== null && auth.user.role === "user" && ( + {auth.user !== null && ( TR/{format(new Date(t.created_at), "yyyyMMdd")}/{t.id} + + | + + + {t.cart_product[0].user.name} +