feat: add app and database modules

This commit is contained in:
2026-05-21 16:05:11 +07:00
parent 37b7e783f5
commit fad70d096b
212 changed files with 23901 additions and 0 deletions
@@ -0,0 +1,45 @@
<?php
namespace App\Services\Notification;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class TelegramService
{
/**
* Send a message to the configured Telegram Chat.
*/
public function sendMessage(string $message): bool
{
$token = get_setting('telegram_bot_token');
$chatId = get_setting('telegram_chat_id');
if (! $token || ! $chatId) {
Log::warning('Telegram Notification skipped: Bot Token or Chat ID not configured.');
return false;
}
try {
$response = Http::post("https://api.telegram.org/bot{$token}/sendMessage", [
'chat_id' => $chatId,
'text' => $message,
'parse_mode' => 'HTML',
'disable_web_page_preview' => true,
]);
if ($response->successful()) {
return true;
}
Log::error('Telegram API Error: '.$response->body());
return false;
} catch (\Exception $e) {
Log::error('Telegram Service Exception: '.$e->getMessage());
return false;
}
}
}