fix logic and tests, update docker CI file
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user