Package ini mendukung logging otomatis ke database untuk setiap request ke WAHA API.
Support: MySQL / MariaDB · PostgreSQL
# MySQL
mysql -u root -p waha < database/sql/mysql_schema.sql
# PostgreSQL
psql -U postgres -d waha -f database/sql/postgres_schema.sqlLaravel — tambahkan di .env:
WAHA_DB_DRIVER=mysql
WAHA_DB_HOST=127.0.0.1
WAHA_DB_PORT=3306
WAHA_DB_DATABASE=waha
WAHA_DB_USERNAME=root
WAHA_DB_PASSWORD=💡 Jika tidak diset, otomatis mengikuti database default Laravel.
Pure PHP:
$config = new WahaConfig(
baseUrl: 'http://localhost:3000',
apiKey: 'your-api-key',
database: [
'driver' => 'mysql',
'host' => '127.0.0.1',
'port' => '3306',
'database' => 'waha',
'username' => 'root',
'password' => '',
]
);php artisan waha:migrate --force
php artisan waha:migrate --rollback --force # rollbackSetiap request WAHA sekarang otomatis tercatat. Tidak perlu kode tambahan.
$waha->sendText('628123456789@c.us', 'Halo!'); // otomatis tercatat di DB| Method | Tercatat di |
|---|---|
startSession() / stopSession() |
waha_sessions |
sendText(), sendImage(), sendFile() |
waha_message_logs + waha_contacts |
reply() |
waha_message_logs + waha_contacts |
sendBulk() |
waha_message_logs (per pesan) |
getMessages() |
waha_messages |
handleIncomingMessage() |
waha_messages + waha_contacts |
| Tabel | Fungsi |
|---|---|
waha_sessions |
Info session (nama, status, QR, waktu connect/disconnect) |
waha_contacts |
Data kontak (phone, nama, blocked, business) |
waha_messages |
Riwayat pesan masuk & keluar |
waha_message_logs |
Log pengiriman (status: pending → sent/failed) |
// Log pesan
$pending = $waha->getMessageLogs('pending');
$sent = $waha->getMessageLogs('sent');
$failed = $waha->getMessageLogs('failed');
// Sessions
$sessions = $waha->getSessions();
// Contacts
$contacts = $waha->getContacts();
$contacts = $waha->getContacts('default'); // per sessionuse Orlinkzz\Waha\Database\DatabaseConnection;
use Orlinkzz\Waha\Database\Repositories\MessageLogRepository;
$connection = new DatabaseConnection($dbConfig);
$repo = new MessageLogRepository($connection->getConnection());
$pending = $repo->findByStatus('pending', 100);public function handleWebhook(Request $request)
{
app('waha')->handleIncomingMessage($request->all());
return response()->json(['status' => 'ok']);
}- Database error tidak menghentikan fungsi utama WAHA
- Error dicatat di
error_logPHP - Jika database tidak dikonfigurasi, WAHA tetap berjalan normal (tanpa logging)
| Masalah | Solusi |
|---|---|
Connection refused |
Cek kredensial DB dan pastikan server berjalan |
Table doesn't exist |
Jalankan migration atau import SQL manual |
| Migration tidak jalan | php artisan config:clear lalu ulang |
src/Database/
├── DatabaseConnection.php
├── Migration.php
├── MigrationManager.php
├── Migrations/
│ ├── BaseMigration.php
│ ├── MySqlMigration.php
│ ├── PostgreSqlMigration.php
│ ├── CreateWahaSessionsTable.php
│ ├── CreateWahaContactsTable.php
│ ├── CreateWahaMessagesTable.php
│ └── CreateWahaMessageLogsTable.php
└── Repositories/
├── SessionRepository.php
├── ContactRepository.php
├── MessageRepository.php
└── MessageLogRepository.php
database/sql/
├── mysql_schema.sql
└── postgres_schema.sql