Init: Hoan thanh kien truc V3 va Filament UI

This commit is contained in:
2026-04-18 02:07:30 +00:00
commit 761b34916b
141 changed files with 15917 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration');
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration');
});
}
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};

View File

@@ -0,0 +1,51 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};

View File

@@ -0,0 +1,16 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void {
Schema::create('projects', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('name');
$table->string('type');
$table->string('address')->nullable();
$table->timestamps();
});
}
public function down(): void { Schema::dropIfExists('projects'); }
};

View File

@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void {
Schema::create('products', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->foreignUuid('project_id')->constrained('projects')->cascadeOnDelete();
$table->string('product_type');
$table->string('code')->unique();
$table->decimal('area', 10, 2);
$table->decimal('price_per_unit', 15, 2)->nullable();
$table->decimal('total_price', 15, 2);
$table->jsonb('custom_data')->nullable(); // Chứa thông tin tầng, view, hướng...
$table->string('status')->default('Đang mở bán');
$table->string('red_book_status')->default('Chưa có dữ liệu');
$table->timestamps();
});
}
public function down(): void { Schema::dropIfExists('products'); }
};

View File

@@ -0,0 +1,19 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void {
Schema::create('customers', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('cmnd_cccd')->unique();
$table->string('full_name');
$table->string('phone')->nullable();
$table->string('email')->nullable();
$table->jsonb('address')->nullable(); // Lưu cấu trúc: số nhà, phường, quận...
$table->date('dob')->nullable();
$table->timestamps();
});
}
public function down(): void { Schema::dropIfExists('customers'); }
};

View File

@@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void {
Schema::create('contracts', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->foreignUuid('product_id')->constrained('products')->cascadeOnDelete();
$table->integer('transfer_order')->default(0);
$table->string('contract_type')->default('HĐMB');
$table->string('contract_number')->unique();
$table->date('signing_date')->nullable();
$table->string('status')->default('Đang hiệu lực');
$table->decimal('total_value', 15, 2);
$table->decimal('paid_amount', 15, 2)->default(0);
// Cột ảo tự động tính số tiền còn lại, dev không cần query tính toán
$table->decimal('remaining_amount', 15, 2)->virtualAs('total_value - paid_amount');
$table->jsonb('metadata')->nullable();
$table->timestamps();
});
}
public function down(): void { Schema::dropIfExists('contracts'); }
};

View File

@@ -0,0 +1,17 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void {
Schema::create('contract_customers', function (Blueprint $table) {
$table->id();
$table->foreignUuid('contract_id')->constrained('contracts')->cascadeOnDelete();
$table->foreignUuid('customer_id')->constrained('customers')->cascadeOnDelete();
$table->string('role')->default('CHỦ SH 1'); // Đồng sở hữu
$table->integer('transfer_order')->default(0);
$table->timestamps();
});
}
public function down(): void { Schema::dropIfExists('contract_customers'); }
};

View File

@@ -0,0 +1,19 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void {
Schema::create('appendices', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->foreignUuid('contract_id')->constrained('contracts')->cascadeOnDelete();
$table->foreignUuid('product_id')->constrained('products')->cascadeOnDelete();
$table->string('type');
$table->integer('apply_from_order')->default(0);
$table->date('signing_date')->nullable();
$table->jsonb('custom_data')->nullable();
$table->timestamps();
});
}
public function down(): void { Schema::dropIfExists('appendices'); }
};

View File

@@ -0,0 +1,20 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void {
Schema::create('settlements', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->foreignUuid('product_id')->constrained('products')->cascadeOnDelete();
$table->string('type'); // "MÓNG", "THÂN", "CP THI CÔNG"
$table->decimal('temp_value', 15, 2)->default(0);
$table->decimal('final_value', 15, 2)->default(0);
$table->decimal('difference', 15, 2)->virtualAs('final_value - temp_value');
$table->string('red_book_status')->nullable();
$table->date('issue_date')->nullable();
$table->timestamps();
});
}
public function down(): void { Schema::dropIfExists('settlements'); }
};

View File

@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void {
Schema::create('payments', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->foreignUuid('contract_id')->constrained('contracts')->cascadeOnDelete();
$table->string('payment_type');
$table->integer('installment_no')->default(1);
$table->decimal('amount', 15, 2);
$table->date('due_date')->nullable();
$table->date('paid_date')->nullable();
$table->string('status')->default('PENDING'); // PENDING, PAID, OVERDUE, CANCELLED
$table->string('receipt_number')->nullable();
$table->jsonb('metadata')->nullable();
$table->timestamps();
});
}
public function down(): void { Schema::dropIfExists('payments'); }
};