-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmailTemplate.php
More file actions
43 lines (37 loc) · 1.31 KB
/
Copy pathEmailTemplate.php
File metadata and controls
43 lines (37 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* DB-backed email template with hardcoded fallbacks.
*
* Slugs in use:
* project-created, project-activated,
* order-placed, order-paid, order-status-changed,
* subscription-activated, report-released, report-approved
*
* Shortcodes: {{user_name}}, {{site_name}}, {{project_title}},
* {{plan_name}}, {{amount}}, {{date}}
*/
class EmailTemplate extends Model
{
protected $fillable = ['slug', 'subject', 'body', 'is_active'];
protected $casts = ['is_active' => 'boolean'];
/**
* Hardcoded fallback templates used when a slug is not found in the DB.
* Structure: ['slug' => ['subject' => '...', 'body' => '...']]
*/
protected static array $defaults = [
'project-created' => [/* subject and body with shortcodes */],
'order-placed' => [/* ... */],
'order-paid' => [/* ... */],
'subscription-activated'=> [/* ... */],
'report-released' => [/* ... */],
'report-approved' => [/* ... */],
];
public static function getBySlug(string $slug): ?array
{
// DB lookup first; fall back to self::$defaults[$slug] if not found
// Returns ['subject' => string, 'body' => string] or null
// ...
}
}