diff --git a/README.md b/README.md index 3e0c3d6..1763855 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,20 @@ MoneyMint is a simple app for tracking expenses, budgeting, and getting an overv MoneyMint

+## Installation +- Clone the repository +- cd moneymint +- composer install or composer update +- cp .env.example .env +- Set up .env file +- php artisan key:generate +- php artisan migrate:fresh --seed +- php artisan serve + +In new terminal +- npm i +- npm run dev + ## Contributing Thank you for considering contributing to the project! Please fork this project and open a pull request against the `main` branch. diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index acd2860..2a35230 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -2,10 +2,15 @@ namespace App\Http\Controllers; +use App\Models\Transaction; +use Illuminate\View\View; + class DashboardController extends Controller { - public function index() + public function index(): View { - return view('app'); + $transactionList = Transaction::all(); // Fetch all income records from the database + + return view('app', compact('transactionList')); } } diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php new file mode 100644 index 0000000..02c57b5 --- /dev/null +++ b/app/Http/Controllers/TransactionController.php @@ -0,0 +1,16 @@ +all()); + return redirect('/'); + } +} diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php new file mode 100644 index 0000000..96e7af1 --- /dev/null +++ b/app/Models/Transaction.php @@ -0,0 +1,15 @@ +id(); + $table->string('title'); + $table->string('description'); + $table->double('credit', 10, 2); + $table->double('debit', 10, 2); + $table->string('status'); + $table->timestamps(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('transaction'); + } +}; diff --git a/database/migrations/2023_08_07_140120_alter_transactions_table.php b/database/migrations/2023_08_07_140120_alter_transactions_table.php new file mode 100644 index 0000000..c07c3f6 --- /dev/null +++ b/database/migrations/2023_08_07_140120_alter_transactions_table.php @@ -0,0 +1,32 @@ +double('credit', 10, 2)->default(0)->nullable()->change(); + $table->double('debit', 10, 2)->default(0)->nullable()->change(); + $table->string('description')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('transactions', function (Blueprint $table) { + $table->double('credit', 10, 2)->change(); + $table->double('debit', 10, 2)->change(); + $table->string('description')->change(); + }); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index a9f4519..5689750 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -18,5 +18,9 @@ public function run(): void // 'name' => 'Test User', // 'email' => 'test@example.com', // ]); + + $this->call([ + TransactionSeeder::class, + ]); } } diff --git a/database/seeders/TransactionSeeder.php b/database/seeders/TransactionSeeder.php new file mode 100644 index 0000000..42d9874 --- /dev/null +++ b/database/seeders/TransactionSeeder.php @@ -0,0 +1,35 @@ + Factory::create()->name(), + 'description' => Factory::create()->text(), + 'credit' => rand(100,10000), + 'status' => Factory::create()->randomElement(['Success', 'Failed', 'Pending']) + ]); + } + for ($i=0; $i <3; $i++) { + Transaction::create([ + 'title' => Factory::create()->name(), + 'description' => Factory::create()->text(), + 'debit' => rand(100,10000), + 'status' => Factory::create()->randomElement(['Success', 'Failed', 'Pending']) + ]); + } + } +} diff --git a/resources/views/app.blade.php b/resources/views/app.blade.php index 37ed561..3d6ae5d 100644 --- a/resources/views/app.blade.php +++ b/resources/views/app.blade.php @@ -51,8 +51,8 @@
- - + +
@@ -137,35 +137,54 @@ Transaction - Amount + Income + Expense Status Date - - -
- - -

Payment to Molly Sanders

-
-
- - - $20,000 - USD - - - success - - - - - + @foreach($transactionList as $transaction) + + +
+ + +

{{ $transaction->title }}

+
+
+ + + ${{ number_format($transaction->credit, 0, '.', ',') }} + USD + + + ${{ number_format($transaction->debit, 0, '.', ',') }} + USD + + + + {{ $transaction->status }} + + + + + + + @endforeach @@ -195,5 +214,91 @@ + + + + + + + + diff --git a/routes/web.php b/routes/web.php index c7c8d1a..2666f82 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,5 +1,7 @@ name('dashboard'); + +Route::post('/transaction', [TransactionController::class, 'store']) + ->name('transaction.store');