reconstruction of the project

This commit is contained in:
root
2026-03-08 16:33:24 -04:00
parent 23b7db1107
commit c8de5f7edc
9157 changed files with 77877 additions and 1073823 deletions
+16 -15
View File
@@ -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;
}
}
}