From 8a3fcadeb9683bc3cba100ae028bed5ef0cc93d5 Mon Sep 17 00:00:00 2001 From: Aji Kamaludin Date: Mon, 13 Dec 2021 11:17:42 +0700 Subject: [PATCH] setup model --- app/Models/Budget.php | 20 ++++++++++ app/Models/Category.php | 18 +++++++++ app/Models/Transaction.php | 21 ++++++++++ ...1_12_13_034402_create_categories_table.php | 3 ++ ..._12_13_035122_create_transaction_table.php | 38 +++++++++++++++++++ .../2021_12_13_035435_create_budget_table.php | 37 ++++++++++++++++++ 6 files changed, 137 insertions(+) create mode 100644 app/Models/Budget.php create mode 100644 app/Models/Category.php create mode 100644 app/Models/Transaction.php create mode 100644 database/migrations/2021_12_13_035122_create_transaction_table.php create mode 100644 database/migrations/2021_12_13_035435_create_budget_table.php diff --git a/app/Models/Budget.php b/app/Models/Budget.php new file mode 100644 index 0000000..5ffff5a --- /dev/null +++ b/app/Models/Budget.php @@ -0,0 +1,20 @@ +id(); + $table->string('name')->nullable(); + $table->string('description')->nullable(); + $table->decimal('default_budget', 12, 2)->default(0); $table->timestamps(); $table->softDeletes(); }); diff --git a/database/migrations/2021_12_13_035122_create_transaction_table.php b/database/migrations/2021_12_13_035122_create_transaction_table.php new file mode 100644 index 0000000..6478ce8 --- /dev/null +++ b/database/migrations/2021_12_13_035122_create_transaction_table.php @@ -0,0 +1,38 @@ +id(); + $table->foreignId('category_id')->references('id')->on('categories')->nullable(); + $table->date('date')->nullable(); + $table->decimal('amount', 12, 2)->default(0); + $table->string('description'); + $table->smallInteger('is_income')->default(0); // 0 expense, 1 income + $table->smallInteger('income_type')->nullable(); // 0 is cash in , 1 is cash out + $table->timestamps(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('transactions'); + } +} diff --git a/database/migrations/2021_12_13_035435_create_budget_table.php b/database/migrations/2021_12_13_035435_create_budget_table.php new file mode 100644 index 0000000..c42b6bc --- /dev/null +++ b/database/migrations/2021_12_13_035435_create_budget_table.php @@ -0,0 +1,37 @@ +id(); + $table->foreignId('category_id')->nullable(); + $table->decimal('rollover', 12, 2)->default(0); + $table->decimal('budget', 12, 2)->default(0); + $table->date('start_date')->nullable(); + $table->date('end_date')->nullable(); + $table->timestamps(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('budgets'); + } +}