diff --git a/.DS_Store b/.DS_Store index 359e843..c37d51b 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/app/.DS_Store b/app/.DS_Store index 32630bc..6d4445f 100644 Binary files a/app/.DS_Store and b/app/.DS_Store differ diff --git a/app/Enums/.DS_Store b/app/Enums/.DS_Store index 4b5683b..38c792f 100644 Binary files a/app/Enums/.DS_Store and b/app/Enums/.DS_Store differ diff --git a/app/Http/Controllers/Api/Admin/Order/OrderController.php b/app/Http/Controllers/Api/Admin/Order/OrderController.php index d6259ca..a9ddc12 100644 --- a/app/Http/Controllers/Api/Admin/Order/OrderController.php +++ b/app/Http/Controllers/Api/Admin/Order/OrderController.php @@ -88,7 +88,7 @@ class OrderController extends Controller public function destroy(int $id): JsonResponse { - $order = Order::with('invoice', 'invoice.invoiceItem')->find($id); + $order = Order::with('invoice', 'invoice.invoiceItems')->find($id); abort_if(!$order, 404, "Can't find order by ID #{$id}"); diff --git a/app/Http/Controllers/admin/OrderController.php b/app/Http/Controllers/admin/OrderController.php index 79ec47c..718ada9 100644 --- a/app/Http/Controllers/admin/OrderController.php +++ b/app/Http/Controllers/admin/OrderController.php @@ -270,7 +270,7 @@ class OrderController extends Controller public function edit(int $id = 0) { - $order = $this->orderRepository->findWithRelationships($id, ['orderItem', 'user', 'customer.invoiceItem.type', 'payment', 'discount', 'invoice.invoiceItem']); + $order = $this->orderRepository->findWithRelationships($id, ['orderItem', 'user', 'customer.invoiceItem.type', 'payment', 'discount', 'invoice.invoiceItems']); if (!$order) { return redirect()->route('administrator.pages.order.index')->withErrors('Can\'t find a order by order id #' . $id); diff --git a/app/Jobs/.DS_Store b/app/Jobs/.DS_Store index 6c6d725..b6f6453 100644 Binary files a/app/Jobs/.DS_Store and b/app/Jobs/.DS_Store differ diff --git a/app/Repositories/.DS_Store b/app/Repositories/.DS_Store index 32e84d3..c38ed63 100644 Binary files a/app/Repositories/.DS_Store and b/app/Repositories/.DS_Store differ diff --git a/app/Services/.DS_Store b/app/Services/.DS_Store index 831d459..b752355 100644 Binary files a/app/Services/.DS_Store and b/app/Services/.DS_Store differ diff --git a/app/Services/OrderService.php b/app/Services/OrderService.php index 4910eb3..614d680 100644 --- a/app/Services/OrderService.php +++ b/app/Services/OrderService.php @@ -68,7 +68,7 @@ class OrderService { DB::transaction(function () use ($order) { if ($order->invoice) { - $order->invoice->invoiceItem()->delete(); + $order->invoice->invoiceItems()->delete(); $order->invoice->delete(); } diff --git a/app/Support/.DS_Store b/app/Support/.DS_Store index e698cb6..46d2d4f 100644 Binary files a/app/Support/.DS_Store and b/app/Support/.DS_Store differ diff --git a/database/.DS_Store b/database/.DS_Store index fe22461..afaf4ef 100644 Binary files a/database/.DS_Store and b/database/.DS_Store differ diff --git a/database/migrations/2024_01_31_145201_customer.php b/database/migrations/2024_01_31_145201_customer.php index 5f44f7a..4221ef0 100644 --- a/database/migrations/2024_01_31_145201_customer.php +++ b/database/migrations/2024_01_31_145201_customer.php @@ -33,6 +33,7 @@ return new class extends Migration { $table->tinyInteger('receive_deposit')->default(1); $table->string('password')->nullable(); $table->integer('credit')->default(0); + $table->integer('unpaid_total')->default(0); $table->integer('total')->default(0); $table->string('identity_number')->nullable(); $table->string('front_identity_number')->nullable(); @@ -44,15 +45,9 @@ return new class extends Migration { $table->timestamps(); $table->softDeletes(); - $table->foreign('province_code') - ->references('code') - ->on('provinces') - ->onDelete('set null'); + $table->foreign('province_code')->references('code')->on('provinces')->onDelete('set null'); - $table->foreign('ward_code') - ->references('code') - ->on('wards') - ->onDelete('set null'); + $table->foreign('ward_code')->references('code')->on('wards')->onDelete('set null'); $table->index('province_code', 'idx_users_province'); $table->index('ward_code', 'idx_users_ward'); diff --git a/database/migrations/2026_08_28_000000_add_legacy_id_to_order_invoice_tables.php b/database/migrations/2026_08_28_000000_add_legacy_id_to_order_invoice_tables.php new file mode 100644 index 0000000..c3c7e1a --- /dev/null +++ b/database/migrations/2026_08_28_000000_add_legacy_id_to_order_invoice_tables.php @@ -0,0 +1,34 @@ +unsignedBigInteger('legacy_id')->nullable()->unique()->after('id'); + }); + + Schema::table('invoices', function (Blueprint $table) { + $table->unsignedBigInteger('legacy_id')->nullable()->unique()->after('id'); + }); + + Schema::table('order_items', function (Blueprint $table) { + $table->unsignedBigInteger('legacy_id')->nullable()->unique()->after('id'); + }); + + Schema::table('invoice_items', function (Blueprint $table) { + $table->unsignedBigInteger('legacy_id')->nullable()->unique()->after('id'); + }); + } + + public function down(): void + { + Schema::table('orders', fn (Blueprint $t) => $t->dropColumn('legacy_id')); + Schema::table('invoices', fn (Blueprint $t) => $t->dropColumn('legacy_id')); + Schema::table('order_items', fn (Blueprint $t) => $t->dropColumn('legacy_id')); + Schema::table('invoice_items', fn (Blueprint $t) => $t->dropColumn('legacy_id')); + } +}; diff --git a/database/migrations/2026_08_28_000001_drop_unique_customers_phone.php b/database/migrations/2026_08_28_000001_drop_unique_customers_phone.php new file mode 100644 index 0000000..f4fb8e6 --- /dev/null +++ b/database/migrations/2026_08_28_000001_drop_unique_customers_phone.php @@ -0,0 +1,26 @@ +dropUnique('customers_phone_unique'); + $table->index('phone'); + }); + } + + public function down(): void + { + Schema::table('customers', function (Blueprint $table) { + $table->dropIndex(['phone']); + $table->unique('phone'); + }); + } +}; diff --git a/database/migrations/2026_08_28_113713_update_column_customers_table.php b/database/migrations/2026_08_28_113713_update_column_customers_table.php new file mode 100644 index 0000000..ca8843f --- /dev/null +++ b/database/migrations/2026_08_28_113713_update_column_customers_table.php @@ -0,0 +1,28 @@ +integer('unpaid_total')->default(0)->comment('Số nợ còn thiếu')->after('total'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('customers', function (Blueprint $table) { + // + }); + } +}; diff --git a/public/.DS_Store b/public/.DS_Store index e55bddd..bd21257 100644 Binary files a/public/.DS_Store and b/public/.DS_Store differ diff --git a/public/fonts/.DS_Store b/public/fonts/.DS_Store index 0f65c47..64959c6 100644 Binary files a/public/fonts/.DS_Store and b/public/fonts/.DS_Store differ diff --git a/resources/.DS_Store b/resources/.DS_Store index a1e376c..1447542 100644 Binary files a/resources/.DS_Store and b/resources/.DS_Store differ diff --git a/storage/.DS_Store b/storage/.DS_Store index bb9a9d2..b698e70 100644 Binary files a/storage/.DS_Store and b/storage/.DS_Store differ diff --git a/tests/.DS_Store b/tests/.DS_Store index 572cc6b..9f794e9 100644 Binary files a/tests/.DS_Store and b/tests/.DS_Store differ