update
This commit is contained in:
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
@@ -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}");
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
@@ -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');
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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::table('orders', function (Blueprint $table) {
|
||||
$table->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'));
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// Multiple legitimate customers can share one phone (agency/accountant managing
|
||||
// several company accounts on one contact number) — WHMCS data confirmed this
|
||||
// isn't dirty data, so uniqueness here was the wrong constraint.
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('customers', function (Blueprint $table) {
|
||||
$table->dropUnique('customers_phone_unique');
|
||||
$table->index('phone');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('customers', function (Blueprint $table) {
|
||||
$table->dropIndex(['phone']);
|
||||
$table->unique('phone');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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::table('customers', function (Blueprint $table) {
|
||||
//
|
||||
$table->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) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Reference in New Issue
Block a user