Skip to content

Commit

Permalink
XW-73 Update dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
mjawaids committed Sep 9, 2024
1 parent 45d6956 commit bb43426
Show file tree
Hide file tree
Showing 6 changed files with 339 additions and 849 deletions.
10 changes: 8 additions & 2 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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']));
}
}
Loading

0 comments on commit bb43426

Please sign in to comment.