- 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>
68 lines
1.4 KiB
PHP
68 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Str;
|
|
|
|
class MailCampaign extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'mail_campaigns';
|
|
|
|
protected $fillable = [
|
|
'uuid',
|
|
'name',
|
|
'template_id',
|
|
'subject',
|
|
'message',
|
|
'variables',
|
|
'cc',
|
|
'bcc',
|
|
'recipient_type',
|
|
'total_recipients',
|
|
'sent_count',
|
|
'failed_count',
|
|
'status',
|
|
'created_by',
|
|
'completed_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'variables' => 'array',
|
|
'total_recipients' => 'integer',
|
|
'sent_count' => 'integer',
|
|
'failed_count' => 'integer',
|
|
'completed_at' => 'datetime',
|
|
];
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function (self $campaign) {
|
|
$campaign->uuid ??= (string) Str::uuid();
|
|
});
|
|
}
|
|
|
|
public function isMarketing(): bool
|
|
{
|
|
return $this->template === null || $this->template->isMarketing();
|
|
}
|
|
|
|
public function logs()
|
|
{
|
|
return $this->hasMany(Mail::class, 'campaign_id');
|
|
}
|
|
|
|
public function template()
|
|
{
|
|
return $this->belongsTo(Template::class, 'template_id');
|
|
}
|
|
|
|
public function creator()
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
}
|
|
}
|