Skip to content

Commit cfc639d

Browse files
committed
feat: transactions list on user dashboard
1 parent 5c48d82 commit cfc639d

File tree

5 files changed

+78
-6
lines changed

5 files changed

+78
-6
lines changed

app/Http/Controllers/Frontend/DashboardController.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Http\Controllers\Controller;
66
use App\Models\Order;
7+
use App\Models\Transaction;
78
use Carbon\Carbon;
89
use Illuminate\Http\Request;
910
use Illuminate\Support\Facades\DB;
@@ -39,4 +40,10 @@ public function index()
3940

4041
return view('frontend.dashboard.index', compact('orders','orderCount', 'itemCount','total'));
4142
}
43+
44+
public function transactions(){
45+
$transactions = Transaction::where('user_id', auth()->id())->paginate(10);
46+
return view('frontend.dashboard.transactions', compact('transactions'));
47+
48+
}
4249
}

resources/views/frontend/dashboard/index.blade.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<header>
77
<h2 class="text-xl font-bold text-gray-900 sm:text-3xl">Dashboard</h2>
88
</header>
9-
109
<div class="mt-8 flex gap-4">
1110
<article class="w-1/2 rounded-lg border border-gray-100 bg-white p-6">
1211
<div class="flex items-center justify-between">
@@ -102,9 +101,7 @@
102101
<div class="mt-4 lg:mt-8 lg:grid lg:grid-cols-4 lg:items-stretch lg:gap-8">
103102
@include('frontend.partials.sidebar')
104103

105-
{{-- <div class="lg:col-span-3"> --}}
106-
@include('frontend.dashboard.orders')
107-
{{-- </div> --}}
104+
@include('frontend.dashboard.orders')
108105
</div>
109106
</div>
110107
</section>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
@extends('frontend.app')
2+
3+
@section('content')
4+
<section class="page-container">
5+
<div class="mx-auto max-w-fit px-4 py-8 sm:px-6 sm:py-12 lg:px-8">
6+
<header>
7+
<h2 class="text-xl font-bold text-gray-900 sm:text-3xl">Transactions</h2>
8+
</header>
9+
<div class="mt-4 lg:mt-8 lg:grid lg:grid-cols-4 lg:items-stretch lg:gap-8">
10+
@include('frontend.partials.sidebar')
11+
<div class="overflow-x-auto lg:col-span-3 h-full">
12+
<table class="table w-full text-xs border border-gray-300 mb-2">
13+
<thead>
14+
<tr class="bg-gray-100">
15+
<th class="border border-gray-300">#</th>
16+
<th class="border border-gray-300">Trx ID</th>
17+
<th class="border border-gray-300">Order ID</th>
18+
<th class="border border-gray-300">Gateway</th>
19+
<th class="border border-gray-300">Total</th>
20+
<th class="border border-gray-300">Currency</th>
21+
<th class="border border-gray-300">Status</th>
22+
<th class="border border-gray-300">Created At</th>
23+
</tr>
24+
</thead>
25+
<tbody>
26+
@foreach ($transactions as $key => $transaction)
27+
<tr>
28+
<th class="border border-gray-300">{{ $transaction->id }}</th>
29+
<th class="border border-gray-300">{{ $transaction->transaction_id }}</th>
30+
<th class="border border-gray-300">{{ $transaction->order_id }}</th>
31+
<th class="border border-gray-300">{{ $transaction->gateway }}</th>
32+
<th class="border border-gray-300">{{ $transaction->amount }}</th>
33+
<th class="border border-gray-300">{{ $transaction->currency }}</th>
34+
<th class="border border-gray-300">
35+
<div class="badge badge-primary badge-xs">{{ $transaction->status }}</div>
36+
</th>
37+
<th class="border border-gray-300">
38+
{{ $transaction->created_at->format('M d, Y h:i A') }}</th>
39+
</tr>
40+
@endforeach
41+
</tbody>
42+
<tfoot>
43+
<tr class="bg-gray-100">
44+
<th class="border border-gray-300">#</th>
45+
<th class="border border-gray-300">Trx ID</th>
46+
<th class="border border-gray-300">Order ID</th>
47+
<th class="border border-gray-300">Gateway</th>
48+
<th class="border border-gray-300">Total</th>
49+
<th class="border border-gray-300">Currency</th>
50+
<th class="border border-gray-300">Status</th>
51+
<th class="border border-gray-300">Created At</th>
52+
</tr>
53+
</tfoot>
54+
</table>
55+
{{ $transactions->links('pagination::tailwind') }}
56+
</div>
57+
</div>
58+
</div>
59+
</section>
60+
@endsection

resources/views/frontend/partials/sidebar.blade.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,23 @@
77

88
<ul class="mt-6 space-y-1">
99
<li>
10-
<a href="#"
11-
class="block rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700">
10+
<a href="{{ route('user.dashboard') }}"
11+
class="block rounded-lg px-4 py-2 text-sm font-medium text-gray-700 {{ request()->is('user/dashboard') ? 'bg-gray-100' : '' }}">
1212
Orders
1313
</a>
1414
</li>
15+
<li>
16+
<a href="{{ route('user.transactions') }}"
17+
class="block rounded-lg px-4 py-2 text-sm font-medium text-gray-700 {{ request()->is('user/transactions') ? 'bg-gray-100' : '' }}">
18+
Transactions
19+
</a>
20+
</li>
1521
<li>
1622
<a href="#" class="block rounded-lg px-4 py-2 text-sm font-medium text-gray-700">
1723
Settings
1824
</a>
1925
</li>
26+
2027
<li>
2128
<a href="{{ route('user.logout') }}"
2229
class="block rounded-lg px-4 py-2 text-sm font-medium text-gray-700">

routes/web.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
->name('user.')
3535
->group(function () {
3636
Route::get('/dashboard', [FrontendDashboardController::class, 'index'])->name('dashboard');
37+
Route::get('/transactions', [FrontendDashboardController::class, 'transactions'])->name('transactions');
3738
Route::get('logout', [LoginController::class, 'userlogout'])->name('logout');
3839
});
3940

0 commit comments

Comments
 (0)