fix logic and tests, update docker CI file
This commit is contained in:
@@ -30,7 +30,7 @@ class AttendanceEmailTemplate extends BaseModel
|
||||
* Fetch a template by code and variant, falling back to 'default' if needed.
|
||||
* Active only.
|
||||
*/
|
||||
public static function getTemplate(string $code, string $variant = 'default'): ?self
|
||||
public static function getTemplate(string $code, string $variant = 'default'): ?array
|
||||
{
|
||||
$row = static::query()
|
||||
->where('code', $code)
|
||||
@@ -39,13 +39,15 @@ class AttendanceEmailTemplate extends BaseModel
|
||||
->first();
|
||||
|
||||
if ($row) {
|
||||
return $row;
|
||||
return $row->toArray();
|
||||
}
|
||||
|
||||
return static::query()
|
||||
$fallback = static::query()
|
||||
->where('code', $code)
|
||||
->where('variant', 'default')
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
return $fallback?->toArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user