feat: Implement mail campaign feature with CRUD operations and email sending capabilities
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user