Files
alrahma_sunday_school_api/app/Models/EmailTemplate.php
T
2026-03-08 16:33:24 -04:00

51 lines
1.1 KiB
PHP
Executable File

<?php
namespace App\Models;
use App\Models\BaseModel;
class EmailTemplate extends BaseModel
{
protected $table = 'email_templates';
// CI model didn't specify timestamps; keep off unless your table has created_at/updated_at.
public $timestamps = false;
protected $fillable = [
'code',
'variant',
'subject',
'body_html',
'is_active',
'updated_by',
'updated_at',
];
protected $casts = [
'is_active' => 'boolean',
];
/**
* Equivalent of CI getActiveTemplates():
* is_active=1, orderBy template_key ASC
*/
public static function getActiveTemplates()
{
return static::query()
->where('is_active', 1)
->orderBy('template_key', 'asc')
->get();
}
/**
* Equivalent of CI findByKey():
* template_key = $key AND is_active=1
*/
public static function findByKey(string $key): ?self
{
return static::query()
->where('template_key', $key)
->where('is_active', 1)
->first();
}
}