added whastapp notification

This commit is contained in:
Jagad R R
2024-12-25 13:37:49 +07:00
parent 0030c0f48e
commit 8c451d0d7a
7 changed files with 142 additions and 3 deletions
@@ -17,6 +17,7 @@ use Illuminate\Support\Str;
use Illuminate\Support\Facades\Mail;
use App\Mail\ExpenseApproved;
use App\Mail\ExpenseRejected;
use App\Helpers\WhatsappHelper;
class FormMeetingSeminarController extends Controller
{
@@ -242,17 +243,21 @@ class FormMeetingSeminarController extends Controller
// Collect all recipients
$recipients = [$form->user->email];
$phoneNumbers = [$form->user->phone];
if ($heads['cabang_head']) {
$recipients[] = $heads['cabang_head']['email'];
$phoneNumbers[] = $heads['cabang_head']['phone'];
}
if ($heads['region_head']) {
$recipients[] = $heads['region_head']['email'];
$phoneNumbers[] = $heads['region_head']['phone'];
}
// Remove duplicate email addresses, if any
$recipients = array_unique($recipients);
$phoneNumbers = array_unique($phoneNumbers);
// Send bulk email
Mail::to($recipients)->send(new ExpenseApproved(
@@ -262,6 +267,9 @@ class FormMeetingSeminarController extends Controller
$total
));
// Send bulk WhatsApp message
WhatsappHelper::approveExpense($phoneNumbers, $expense_number);
session()->flash('success', 'Form has been approved.');
return redirect()->back();
}
@@ -318,17 +326,21 @@ class FormMeetingSeminarController extends Controller
// Collect all recipients
$recipients = [$form->user->email];
$phoneNumbers = [$form->user->phone];
if ($heads['cabang_head']) {
$recipients[] = $heads['cabang_head']['email'];
$phoneNumbers[] = $heads['cabang_head']['phone'];
}
if ($heads['region_head']) {
$recipients[] = $heads['region_head']['email'];
$phoneNumbers[] = $heads['region_head']['phone'];
}
// Remove duplicate email addresses, if any
$recipients = array_unique($recipients);
$phoneNumbers = array_unique($phoneNumbers);
// Send bulk email
Mail::to($recipients)->send(new ExpenseRejected(
@@ -338,6 +350,9 @@ class FormMeetingSeminarController extends Controller
$total
));
// Send bulk WhatsApp message
WhatsappHelper::rejectExpense($phoneNumbers, $expense_number);
session()->flash('success', 'Form has been rejected.');
return redirect()->back();
}