fix(customer): lưu và trả địa chỉ khách hàng

Bảng customers chỉ có cột address nên address_1/address_2 từ form admin bị bỏ khi validate.
Thêm cột address_2, fillable, rule validate và trả đủ field địa chỉ trong CustomerResource.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
baodev0
2026-10-27 08:37:57 +07:00
co-authored by Claude Sonnet 5.5
parent fc765ad007
commit e1ffbf52fe
4 changed files with 33 additions and 1 deletions
+2 -1
View File
@@ -28,7 +28,8 @@ class CreateCustomerRequest extends FormRequest
'status' => 'nullable|integer|in:0,1,2,3',
'company' => 'nullable',
'phone' => 'nullable',
'address' => 'nullable',
'address' => 'nullable|string|max:255',
'address_2' => 'nullable|string|max:255',
'city' => 'nullable',
'state' => 'nullable',
'postcode' => 'nullable',
@@ -16,6 +16,12 @@ class CustomerResource extends JsonResource
'email' => $this->email,
'phone' => $this->phone,
'company' => $this->company,
'address' => $this->address,
'address_2' => $this->address_2,
'city' => $this->city,
'state' => $this->state,
'postcode' => $this->postcode === null ? null : (string) $this->postcode,
'country' => $this->country,
'note' => $this->note,
'status' => (int) $this->status,
'total' => (int) $this->total,
+1
View File
@@ -52,6 +52,7 @@ class Customer extends Authenticatable implements JWTSubject
'username',
'avatar',
'address',
'address_2',
'state',
'city',
'postcode',
@@ -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::table('customers', function (Blueprint $table) {
$table->string('address', 255)->nullable()->change();
$table->string('address_2', 255)->nullable()->after('address');
});
}
public function down(): void
{
Schema::table('customers', function (Blueprint $table) {
$table->dropColumn('address_2');
$table->string('address', 100)->nullable()->change();
});
}
};