add notif expense created

This commit is contained in:
Jagad R R
2025-01-09 13:22:56 +07:00
parent 664ff183cd
commit ace9ea2c9c
20 changed files with 822 additions and 166 deletions
+30
View File
@@ -98,4 +98,34 @@ class WhatsappHelper
return $response->getBody()->getContents();
}
public static function newExpense($phones, $expense_number, $url = null)
{
$client = new Client();
if ($url && !preg_match('/^https?:\/\//', $url)) {
$url = 'https://' . $url;
}
$data = [];
foreach ($phones as $phone) {
$data[] = [
'phone' => $phone,
'message' => 'Pengajuan pengeluaran baru dengan nomor *' . $expense_number . '* telah dibuat. Silahkan buka link berikut untuk melihat detailnya: ' . $url,
'source' => 'web'
];
}
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
'headers' => [
'Authorization' => env('WABLAS_TOKEN'),
'Content-Type' => 'application/json'
],
'json' => [
'data' => $data
]
]);
return $response->getBody()->getContents();
}
}