Files
portal-api/app/Models/Mail.php
T
baodev0andClaude Opus 5.5 94614d9cb3 feat: khởi tạo/huỷ domain Plesk qua job, gửi mail hoá đơn qua queue, đính kèm triển khai
- ProvisionDnsDomainJob/SuspendDnsDomainJob: tạo domain admin lên Plesk, huỷ = suspend (is_created=3)
- Khách xem zone DNS được gán ở /dich-vu/domain, quản lý bản ghi A/AAAA/CNAME/TXT/MX/SRV
- send-mail hoá đơn đẩy SendInvoiceMailJob, preview + sửa nội dung, ghi mail.order_id
- invoice_attachments.type (payment_proof/deployment)
- CacheService xoá theo SCAN pattern, Redis không persistent mặc định
- Backfill transactions.public_code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 09:56:18 +07:00

61 lines
1.5 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Mail extends Model
{
use HasFactory;
protected $table = 'mail';
protected $fillable = [
'campaign_id',
'template_id',
'subject',
'from_address',
'to',
'cc',
'bcc',
'customer_id',
'order_id',
'sent_by',
'message',
'status'
];
// ponytail: status is stored as tinyint (1=sent, 2=failed, 3=pending) but the
// admin API/UI contract expects string enums; map it here so every reader agrees.
public const STATUS_MAP = [1 => 'sent', 2 => 'failed', 3 => 'pending'];
protected function status(): \Illuminate\Database\Eloquent\Casts\Attribute
{
return \Illuminate\Database\Eloquent\Casts\Attribute::make(
get: fn ($value) => self::STATUS_MAP[$value] ?? self::STATUS_MAP[1],
set: fn ($value) => is_string($value) ? (array_search($value, self::STATUS_MAP, true) ?: 1) : $value,
);
}
public function campaign()
{
return $this->belongsTo(MailCampaign::class, 'campaign_id');
}
public function customer()
{
return $this->belongsTo(Customer::class, 'customer_id');
}
public function sender()
{
return $this->belongsTo(User::class, 'sent_by');
}
public function template()
{
return $this->belongsTo(Template::class, 'template_id');
}
}