add superadmin dashboard. subscriptions

This commit is contained in:
root
2026-01-13 20:03:16 +03:00
parent 3c24c250e5
commit edb4df7e37
36 changed files with 3329 additions and 100 deletions
+32
View File
@@ -65,4 +65,36 @@ class EmailLibrary
return false;
}
}
/**
* Отправить письмо для сброса пароля
*/
public function sendPasswordResetEmail(string $email, string $name, string $token): bool
{
$emailConfig = config('Email');
// Генерируем URL для сброса пароля
$resetUrl = base_url('/forgot-password/reset/' . $token);
// Рендерим HTML письма через Twig
$twig = Services::twig();
$htmlBody = $twig->render('emails/password_reset', [
'name' => $name,
'reset_url' => $resetUrl,
'app_name' => $emailConfig->fromName ?? 'Бизнес.Точка',
]);
$emailer = Services::email($emailConfig);
$emailer->setTo($email);
$emailer->setFrom($emailConfig->fromEmail, $emailConfig->fromName);
$emailer->setSubject('Сброс пароля');
$emailer->setMessage($htmlBody);
try {
return $emailer->send();
} catch (\Exception $e) {
log_message('error', 'Ошибка отправки email: ' . $e->getMessage());
return false;
}
}
}
@@ -42,6 +42,11 @@ class TwigGlobalsExtension extends AbstractExtension
new TwigFunction('role_badge', [$this, 'roleBadge'], ['is_safe' => ['html']]),
new TwigFunction('status_badge', [$this, 'statusBadge'], ['is_safe' => ['html']]),
new TwigFunction('get_all_roles', [$this, 'getAllRoles'], ['is_safe' => ['html']]),
// System role functions (superadmin)
new TwigFunction('is_superadmin', [$this, 'isSuperadmin'], ['is_safe' => ['html']]),
new TwigFunction('is_system_admin', [$this, 'isSystemAdmin'], ['is_safe' => ['html']]),
new TwigFunction('get_system_role', [$this, 'getSystemRole'], ['is_safe' => ['html']]),
];
}
@@ -137,6 +142,26 @@ class TwigGlobalsExtension extends AbstractExtension
return '<span class="badge ' . esc($color) . '">' . esc($label) . '</span>';
}
// ========================================
// System Role Functions (superadmin)
// ========================================
public function isSuperadmin(): bool
{
return service('access')->isSuperadmin();
}
public function isSystemAdmin(): bool
{
return service('access')->isSystemAdmin();
}
public function getSystemRole(): ?string
{
return service('access')->getSystemRole();
}
public function statusBadge(string $status): string
{
$colors = [