| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Factories\HasFactory;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Support\Str;
- class EmailTemplate extends Model
- {
- use HasFactory;
- protected $fillable = [
- 'name',
- 'content',
- 'created_by'
- ];
- protected $casts = [
- 'created_at' => 'datetime',
- 'updated_at' => 'datetime',
- ];
- public function creator()
- {
- return $this->belongsTo(User::class, 'created_by');
- }
- public function scheduledEmails()
- {
- return $this->hasMany(EmailScheduled::class, 'template_id');
- }
- public function getWordCountAttribute()
- {
- return str_word_count(strip_tags($this->content));
- }
- public function getPreviewAttribute()
- {
- return Str::limit(strip_tags($this->content), 100);
- }
- }
|