- 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>
47 lines
1.6 KiB
PHP
47 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Api\Client;
|
|
|
|
use App\Enums\Client\ClientGender;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class ClientUpdateRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return auth('client')->check();
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'fullname' => 'required|string|max:255',
|
|
'phone' => 'sometimes|required|string|max:20',
|
|
'company' => 'nullable|string|max:255',
|
|
'address' => 'nullable|string|max:500',
|
|
'province_code' => ['nullable', 'string', Rule::exists('provinces', 'code')],
|
|
'ward_code' => [
|
|
'nullable',
|
|
'string',
|
|
'required_with:province_code',
|
|
Rule::exists('wards', 'code')->where('province_code', $this->input('province_code')),
|
|
],
|
|
'gender' => ['nullable', Rule::enum(ClientGender::class)],
|
|
'birthday' => ['nullable', 'date_format:Y-m-d', 'before_or_equal:today', 'after:1900-01-01'],
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'fullname.required' => 'Họ tên là bắt buộc',
|
|
'phone.required' => 'Số điện thoại là bắt buộc',
|
|
'province_code.exists' => 'Tỉnh/Thành phố không hợp lệ',
|
|
'ward_code.required_with' => 'Vui lòng chọn Phường/Xã',
|
|
'ward_code.exists' => 'Phường/Xã không thuộc Tỉnh/Thành phố đã chọn',
|
|
'birthday.before_or_equal' => 'Ngày sinh không được ở tương lai',
|
|
];
|
|
}
|
|
}
|