update
This commit is contained in:
@@ -20,4 +20,26 @@ class Mail extends Model
|
||||
'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 customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class, 'customer_id');
|
||||
}
|
||||
|
||||
public function template()
|
||||
{
|
||||
return $this->belongsTo(Template::class, 'template_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user