🗃️ Make database

This commit is contained in:
TiclemFR
2023-12-29 17:13:50 +01:00
parent 884eb3011a
commit 24e7eae6c3
21 changed files with 461 additions and 1 deletions

11
app/Models/Expanse.php Normal file
View File

@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Expanse extends Model
{
use HasFactory;
}

13
app/Models/History.php Normal file
View File

@@ -0,0 +1,13 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class History extends Model
{
use HasFactory;
public $incrementing = false;
}

11
app/Models/Income.php Normal file
View File

@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Income extends Model
{
use HasFactory;
}

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class PrevisionalExpanse extends Model
{
use HasFactory;
}

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class PrevisionalIncome extends Model
{
use HasFactory;
}

12
app/Models/Recurring.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Recurring extends Model
{
use HasFactory;
public $timestamps = false;
}

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class RecurringExpense extends Model
{
use HasFactory;
}

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class RecurringIncomes extends Model
{
use HasFactory;
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class TypeExpanse extends Model
{
use HasFactory;
public $timestamps = false;
}

12
app/Models/TypeIncome.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class TypeIncome extends Model
{
use HasFactory;
public $timestamps = false;
}

View File

@@ -17,7 +17,8 @@ return new class extends Migration
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->string('role')->default('user');
$table->double('account')->default(0);
$table->timestamps();
});
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('histories', function (Blueprint $table) {
$table->unsignedInteger('year');
$table->unsignedInteger('month');
$table->unsignedBigInteger('id_user');
$table->double('amount');
$table->foreign('id_user')
->references('id')->on('users');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('histories');
}
};

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('type_expanses', function (Blueprint $table) {
$table->id();
$table->string('label');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('type_expanses');
}
};

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('recurrings', function (Blueprint $table) {
$table->id();
$table->string('label');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('recurrings');
}
};

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('type_incomes', function (Blueprint $table) {
$table->id();
$table->string('label');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('type_incomes');
}
};

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('previsional_expanses', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('id_user');
$table->unsignedBigInteger('id_type_expanse');
$table->double('amount')->default(0);
$table->string('description', 200)->default('');
$table->date('date');
$table->foreign('id_user')
->references('id')->on('users');
$table->foreign('id_type_expanse')
->references('id')->on('type_expanses');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('previsional_expanses');
}
};

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('expanses', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('id_user');
$table->unsignedBigInteger('id_type_expanse');
$table->double('amount')->default(0);
$table->string('description', 200)->default('');
$table->date('date');
$table->foreign('id_user')
->references('id')->on('users');
$table->foreign('id_type_expanse')
->references('id')->on('type_expanses');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('expanses');
}
};

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('recurring_expenses', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('id_type_expanse');
$table->unsignedBigInteger('id_recurring');
$table->unsignedBigInteger('id_user');
$table->double('amount')->default(0);
$table->string('description', 200)->default('');
$table->date('date');
$table->date('end_date')->nullable();
$table->foreign('id_type_expanse')
->references('id')->on('type_expanses');
$table->foreign('id_recurring')
->references('id')->on('recurrings');
$table->foreign('id_user')
->references('id')->on('users');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('recurring_expenses');
}
};

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('recurring_incomes', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('id_type_expanse');
$table->unsignedBigInteger('id_recurring');
$table->unsignedBigInteger('id_user');
$table->double('amount')->default(0);
$table->string('description', 200)->default('');
$table->date('date');
$table->date('end_date')->nullable();
$table->foreign('id_type_expanse')
->references('id')->on('type_expanses');
$table->foreign('id_recurring')
->references('id')->on('recurrings');
$table->foreign('id_user')
->references('id')->on('users');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('recurring_incomes');
}
};

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('incomes', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('id_user');
$table->unsignedBigInteger('id_type_income');
$table->double('amount');
$table->string('description', 200)->default('');
$table->date('date');
$table->foreign('id_user')
->references('id')->on('users');
$table->foreign('id_type_income')
->references('id')->on('type_incomes');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('incomes');
}
};

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('previsional_incomes', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('id_user');
$table->unsignedBigInteger('id_type_income');
$table->double('amount');
$table->string('description', 200)->default('');
$table->date('date');
$table->foreign('id_user')
->references('id')->on('users');
$table->foreign('id_type_income')
->references('id')->on('type_incomes');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('previsional_incomes');
}
};