fix logic and tests, update docker CI file

This commit is contained in:
root
2026-03-09 15:58:44 -04:00
parent 1cb3573d4b
commit 79e44fe037
188 changed files with 1776 additions and 524 deletions
+17 -1
View File
@@ -23,8 +23,24 @@ class EmailTemplate extends BaseModel
protected $casts = [
'is_active' => 'boolean',
'updated_by' => 'integer',
];
public static function getTemplate(string $code, string $variant = 'default'): ?self
{
$row = static::query()
->where('code', $code)
->where('is_active', 1)
->where(function ($q) use ($variant) {
$q->where('variant', $variant)
->orWhere('variant', 'default');
})
->orderByRaw("CASE WHEN variant = ? THEN 0 ELSE 1 END", [$variant])
->first();
return $row;
}
/**
* Equivalent of CI getActiveTemplates():
* is_active=1, orderBy template_key ASC
@@ -48,4 +64,4 @@ class EmailTemplate extends BaseModel
->where('is_active', 1)
->first();
}
}
}