feat: Implement mail campaign feature with CRUD operations and email sending capabilities

This commit is contained in:
baodev0
2026-08-21 16:57:32 +07:00
parent 8d0a5322ea
commit eec2c5906e
11 changed files with 593 additions and 3 deletions
+55
View File
@@ -0,0 +1,55 @@
<?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',
'cc',
'bcc',
'recipient_type',
'total_recipients',
'sent_count',
'failed_count',
'status',
'created_by',
'completed_at',
];
protected $casts = [
'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 logs()
{
return $this->hasMany(Mail::class, 'campaign_id');
}
public function template()
{
return $this->belongsTo(Template::class, 'template_id');
}
}