feat: Add customer notes functionality and enhance invoice/order models with date fields

This commit is contained in:
baodev0
2026-07-25 11:05:34 +07:00
parent cd61e1d242
commit 4daf52ef3e
9 changed files with 378 additions and 1 deletions
@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
// ponytail: raw SQL for the column type change — this repo doesn't have doctrine/dbal installed
return new class extends Migration
{
public function up(): void
{
Schema::table('note', function (Blueprint $table) {
$table->unsignedBigInteger('service_id')->nullable()->index()->after('customer_id');
});
DB::statement('ALTER TABLE note MODIFY note LONGTEXT NULL');
}
public function down(): void
{
Schema::table('note', function (Blueprint $table) {
$table->dropColumn('service_id');
});
DB::statement('ALTER TABLE note MODIFY note VARCHAR(255) NULL');
}
};
@@ -0,0 +1,18 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
// ponytail: raw SQL for the column type change — this repo doesn't have doctrine/dbal installed
return new class extends Migration
{
public function up(): void
{
DB::statement('ALTER TABLE note MODIFY note LONGTEXT NULL');
}
public function down(): void
{
DB::statement('ALTER TABLE note MODIFY note TEXT NULL');
}
};
@@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('invoices', function (Blueprint $table) {
$table->date('date')->nullable()->after('invoice_number');
});
// Backfill: ngày lập = ngày tạo, cho các hóa đơn đã có sẵn.
DB::statement('UPDATE invoices SET date = DATE(created_at) WHERE date IS NULL');
}
public function down(): void
{
Schema::table('invoices', function (Blueprint $table) {
$table->dropColumn('date');
});
}
};
@@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('orders', function (Blueprint $table) {
$table->date('date')->nullable()->after('order_num');
});
// Backfill: ngày đặt = ngày tạo, cho các đơn hàng đã có sẵn.
DB::statement('UPDATE orders SET date = DATE(created_at) WHERE date IS NULL');
}
public function down(): void
{
Schema::table('orders', function (Blueprint $table) {
$table->dropColumn('date');
});
}
};