feat: hồ sơ khách (ngày sinh, tỉnh/phường theo mã), gộp menu + nút tắt, thông báo theo uuid

- PUT v1/client/update: gender theo enum ClientGender (0 Nam/1 Nữ), thêm
  birthday (cột mới), province_code/ward_code validate theo bảng provinces/wards
  (phường phải thuộc tỉnh). Migration nạp dữ liệu hành chính 2025 từ
  province_ward_import.sql (chỉ bảng trống), API GET v1/provinces[/{code}/wards].
- CustomerObserver/OrderObserver log giá trị cũ bằng getRawOriginal: getOriginal
  trả enum object, nối chuỗi gây 500 khi khách đổi giới tính.
- ClientResource: các cờ trả boolean, CCCD chỉ trả cccd_updated (không lộ ảnh/số).
- GET v1/setting/menu trả cả items + quick_links, bỏ v1/setting/quick-links.
- Thông báo admin/khách tra theo uuid thay vì id tự tăng.
- Chặn gửi template marketing cho khách đã tắt nhận email marketing.
- Xoá ProvinceWardSeeder và Customer::$updatable không dùng.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
baodev0
2026-10-13 16:03:18 +07:00
co-authored by Claude Opus 5.5
parent 12d5b4951c
commit bf78f3b810
30 changed files with 461 additions and 183 deletions
@@ -5,8 +5,6 @@ namespace App\Http\Controllers\Api\Client\Concerns;
use App\Http\Requests\Api\Client\ClientUpdateCccdRequest;
use App\Http\Requests\Api\Client\ClientUpdateRequest;
use App\Http\Resources\Api\Client\ClientResource;
use App\Models\Customer;
use Illuminate\Support\Facades\Storage;
trait ManagesClientProfile
{
@@ -37,7 +35,7 @@ trait ManagesClientProfile
public function updateCccd(ClientUpdateCccdRequest $request)
{
// Disk private: ảnh chỉ đọc được qua route signed `api.client.cccd`.
// Disk private: phía client chỉ nhận trạng thái đã cập nhật, không nhận đường dẫn ảnh.
$frontUrl = $request->file('cmnd_before')->store('cccd', 'local');
$backUrl = $request->file('cmnd_after')->store('cccd', 'local');
@@ -69,26 +67,4 @@ trait ManagesClientProfile
]);
}
/**
* Trả ảnh CCCD từ disk private. Route yêu cầu chữ ký (signed:relative) nên không cần
* Bearer — chữ ký do ClientResource cấp cho đúng chủ tài khoản, hết hạn sau 60 phút.
*/
public function cccdImage(int $customer, string $side)
{
$path = Customer::findOrFail($customer)->{$side === 'front' ? 'front_identity_number' : 'back_identity_number'};
abort_unless($path && str_starts_with($path, 'cccd/') && Storage::disk('local')->exists($path), 404);
$mime = match (strtolower(pathinfo($path, PATHINFO_EXTENSION))) {
'png' => 'image/png',
'webp' => 'image/webp',
default => 'image/jpeg',
};
return Storage::disk('local')->response($path, "cccd-{$side}", [
'Content-Type' => $mime,
'Content-Disposition' => "inline; filename=\"cccd-{$side}\"",
'Cache-Control' => 'private, no-store',
]);
}
}