setup model

pull/1/head
Aji Kamaludin 3 years ago
parent d5a8e6b7c0
commit 8a3fcadeb9
No known key found for this signature in database
GPG Key ID: 1DA43CE768971389

@ -0,0 +1,20 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Budget extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = [
'category_id',
'rollover',
'budget',
'start_date',
'end_date',
];
}

@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Category extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = [
'name',
'description',
'default_budget'
];
}

@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Transaction extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = [
'category_id',
'date',
'amount',
'description',
'is_income',
'income_type',
];
}

@ -15,6 +15,9 @@ class CreateCategoriesTable extends Migration
{ {
Schema::create('categories', function (Blueprint $table) { Schema::create('categories', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name')->nullable();
$table->string('description')->nullable();
$table->decimal('default_budget', 12, 2)->default(0);
$table->timestamps(); $table->timestamps();
$table->softDeletes(); $table->softDeletes();
}); });

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTransactionTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('transactions', function (Blueprint $table) {
$table->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');
}
}

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateBudgetTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('budgets', function (Blueprint $table) {
$table->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');
}
}
Loading…
Cancel
Save