reconstruction of the project
This commit is contained in:
@@ -2,11 +2,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class AttendanceEmailTemplate extends Model
|
||||
class AttendanceEmailTemplate extends BaseModel
|
||||
{
|
||||
protected $table = 'email_templates';
|
||||
|
||||
// ✅ Laravel will auto-manage created_at / updated_at
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'variant',
|
||||
@@ -16,35 +20,32 @@ class AttendanceEmailTemplate extends Model
|
||||
'updated_by',
|
||||
'updated_at',
|
||||
];
|
||||
public $timestamps = false;
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
'is_active' => 'boolean',
|
||||
'updated_by' => 'integer',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* Fetch an active template by code and variant, falling back to default.
|
||||
* Fetch a template by code and variant, falling back to 'default' if needed.
|
||||
* Active only.
|
||||
*/
|
||||
public function getTemplate(string $code, string $variant = 'default'): ?array
|
||||
public static function getTemplate(string $code, string $variant = 'default'): ?self
|
||||
{
|
||||
$row = self::query()
|
||||
$row = static::query()
|
||||
->where('code', $code)
|
||||
->where('variant', $variant)
|
||||
->where('is_active', true)
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
if ($row) {
|
||||
return $row->toArray();
|
||||
return $row;
|
||||
}
|
||||
|
||||
$row = self::query()
|
||||
return static::query()
|
||||
->where('code', $code)
|
||||
->where('variant', 'default')
|
||||
->where('is_active', true)
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
return $row ? $row->toArray() : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user