From bb434268c173dd27fa648091db5b25201f07d035 Mon Sep 17 00:00:00 2001 From: Muhammad Jawaid Shamshad <8084794+mjawaids@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:03:46 +0500 Subject: [PATCH] XW-73 Update dashboard --- app/Http/Controllers/HomeController.php | 10 +- resources/views/dashboard.blade.php | 576 +----------------- .../transactions/add-edit-modal.blade.php | 107 ++++ .../transactions/create-widget.blade.php | 44 +- resources/views/transactions/index.blade.php | 280 +-------- resources/views/transactions/list.blade.php | 171 ++++++ 6 files changed, 339 insertions(+), 849 deletions(-) create mode 100644 resources/views/transactions/add-edit-modal.blade.php create mode 100644 resources/views/transactions/list.blade.php diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index b14e952..298c2e4 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -5,6 +5,7 @@ use App\Models\Account; use App\Models\Category; use App\Models\Wallet; +use Carbon\Carbon; use Illuminate\Support\Facades\Auth; class HomeController extends Controller @@ -24,11 +25,16 @@ public function index() { $pageTitle = "Transactions"; - $transactions = Auth::user()->transactions()->orderByDesc('id')->get(); + $paginatedTransactions = Auth::user()->transactions()->orderByDesc('transaction_date')->paginate(10); + + $transactions = $paginatedTransactions->getCollection()->groupBy(function ($transaction) { + return Carbon::parse($transaction->transaction_date)->format('d M Y'); + }); + $categories = Category::where('user_id', '=', auth()->id())->get(); $accounts = Account::where('user_id', '=', auth()->id())->get(); $wallets = Wallet::where('user_id', '=', auth()->id())->get(); - return view('dashboard', compact(['transactions', 'categories', 'accounts', 'wallets', 'pageTitle'])); + return view('dashboard', compact(['paginatedTransactions', 'transactions', 'categories', 'accounts', 'wallets', 'pageTitle'])); } } diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 4e31f05..6738828 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -1,573 +1,31 @@ @extends('layouts.app') @section('content') -
-
-
-
-
-
-
- -
- -
- 4562   1122   4594   7852
-
-
-
-

Card Holder

-
Jack Peterson
-
-
-

Expires

-
11/22
-
-
-
- logo -
-
-
-
-
-
-
-
- @foreach ($accounts as $account) - @if ($loop->iteration == 3) - @break - @endif -
-
-
-
- -
-
-
-
{{ $account->name }}
- {{ $account->type }} -
-
{{ $account->currency }} {{ $account->balance }}
-
-
-
- @endforeach -
-
-
-
-
-
-
-
Payment Method
-
- -
-
-
-
-
-
- logo -
- ****   ****   ****   7852
- -
-
-
-
- logo -
- ****   ****   ****   5248
- -
-
-
-
-
-
-
-
-
- @php - $groupedTransactions = $transactions->groupBy(function ($transaction) { - return \Carbon\Carbon::parse($transaction->transaction_date)->format('d M Y'); - }); - @endphp -
-
-
-
-
Your Transactions
-
-
- - {{-- Date filter can go here if needed --}} -
-
-
-
- @foreach ($groupedTransactions as $date => $transactionsOnDate) -
{{ $date }} -
-
    - @foreach ($transactionsOnDate as $transaction) -
  • -
    - -
    -
    - {{ $transaction->category ? $transaction->category->name : 'N/A' }} -
    - {{ $transaction->details }} -
    -
    -
    - {{ $transaction->src_account->name }} -
    -
    - {{ $transaction->type == 1 ? '- ' : '+ ' }}${{ number_format($transaction->amount, 2) }} -
    -
  • - @endforeach -
- @endforeach -
-
-
-
-
-
-
-
-
-
-

Built by developers

-
Soft UI Dashboard
-

From colors, cards, typography to complex elements, you will - find the full documentation.

- - Read More - - -
-
-
-
- waves -
- rocket -
-
-
-
-
-
-
-
-
-
- -
-
Work with the rockets
-

Wealth creation is an evolutionarily recent positive-sum game. It - is all about who take the opportunity first.

- - Read More - - -
-
-
-
-
-
-
-
-
-
-
- -
-
-
Active Users
-

(+23%) than last week -

-
-
-
-
-
- - document - - - - - - - - - - - - -
-

Users

-
-

36K

-
-
-
-
-
-
-
- - spaceship - - - - - - - - - - - - - - - -
-

Clicks

-
-

2m

-
-
-
-
-
-
-
- - credit-card - - - - - - - - - - - - -
-

Sales

-
-

435$

-
-
-
-
-
-
-
- - settings - - - - - - - - - - - - - - -
-

Items

-
-

43

-
-
-
-
-
-
-
-
+
+ +
+
+ @include('transactions.list', ['transactions' => $transactions])
-
-
-
-
Sales overview
-

- - 4% more in 2021 -

-
-
-
- -
-
-
+ @include('transactions.add-edit-modal') + +
+ @include('transactions.create-widget', ['transaction' => null])
+
@endsection @section('script') - - @endsection diff --git a/resources/views/transactions/add-edit-modal.blade.php b/resources/views/transactions/add-edit-modal.blade.php new file mode 100644 index 0000000..81ec88f --- /dev/null +++ b/resources/views/transactions/add-edit-modal.blade.php @@ -0,0 +1,107 @@ + + diff --git a/resources/views/transactions/create-widget.blade.php b/resources/views/transactions/create-widget.blade.php index 61ba0cf..e3e4808 100644 --- a/resources/views/transactions/create-widget.blade.php +++ b/resources/views/transactions/create-widget.blade.php @@ -9,7 +9,7 @@ -
+ + +
+
+ + + +
@@ -67,16 +87,17 @@ class="form-control @error('transaction_date') is-invalid @enderror" name="trans class="form-control @error('category_id') is-invalid @enderror" autocomplete="category_id"> @foreach ($categories as $category) - + {{ $category->name }} + - @if (count($category->subcategories)) - @include ('categories.subCategoryOption', ['subcategories' => $category->subcategories, 'indent' => 1]) - @endif + @if (count($category->subcategories)) + @include ('categories.subCategoryOption', ['subcategories' => $category->subcategories, 'indent' => 1]) + @endif @endforeach @@ -128,7 +149,8 @@ class="form-control @error('src_account_id') is-invalid @enderror" required @foreach ($accounts as $account) + {{ $account->name }} + @endforeach @@ -152,7 +174,8 @@ class="form-control @error('dest_account_id') is-invalid @enderror" autocomplete @foreach ($accounts as $account) + {{ $account->name }} + @endforeach @@ -182,7 +205,8 @@ class="form-control @error('wallet_id') is-invalid @enderror" required autocompl @foreach ($wallets as $wallet) + {{ $wallet->name }} + @endforeach @@ -231,4 +255,4 @@ class="form-control @error('wallet_id') is-invalid @enderror" required autocompl
-
+
\ No newline at end of file diff --git a/resources/views/transactions/index.blade.php b/resources/views/transactions/index.blade.php index 8c94138..f99ca21 100644 --- a/resources/views/transactions/index.blade.php +++ b/resources/views/transactions/index.blade.php @@ -169,285 +169,9 @@ @section('content')
-
-
-
-
-
Your Transactions
-
-
-
- -
-
-
-
-
- @if ($transactions->isEmpty()) -
- -
No Transactions Found
-

You have no transactions to display at the moment. Start adding - transactions to see them here.

-
- @else - @foreach ($transactions as $date => $transactionsOnDate) -
{{ $date }}
-
    - @foreach ($transactionsOnDate as $transaction) -
  • -
    - -
    -
    -
    -
    - -
    -
    - {{ $transaction->type == 3 ? 'Transfer' : ($transaction->category ? $transaction->category->name : 'N/A') }} -
    - {{ $transaction->details }} - - - @if ($transaction->type == 3) - {{ $transaction->src_account->name }} - - {{ $transaction->dest_account->name }} - @else - {{ $transaction->src_account->name }} - @endif - - -
    -
    -
    -
    -
    -
    -
    - - @if ($transaction->type == 3) - {{ $transaction->src_account->name }} - - {{ $transaction->dest_account->name }} - @else - {{ $transaction->src_account->name }} - @endif - -
    -
    -
    -
    - {{ $transaction->type == 3 ? '' : ($transaction->type == 1 ? '-' : '+') }}${{ number_format($transaction->amount, 2) }} -
    -
    -
    - - @if ($transaction->type == 3) - {{ $transaction->src_account->name }} - - {{ $transaction->dest_account->name }} - @else - {{ $transaction->src_account->name }} - @endif - -
    -
    -
    -
    -
    -
    -
    - - - - -
    -
  • - @endforeach -
- @endforeach -
- -
- @endif -
-
-
- - + @include('transactions.add-edit-modal') @endsection @section('script')