"19-02-2026"; 2 tanggal => "a dan b"; 3+ => "a, b, dan c". */ private function formatDaftarTanggal(array $daftarTanggal): string { $daftarTanggal = array_values($daftarTanggal); $terakhir = array_pop($daftarTanggal); if ($daftarTanggal === []) { return (string) $terakhir; } return implode(', ', $daftarTanggal).(count($daftarTanggal) > 1 ? ',' : '')." dan $terakhir"; } public function sendPengajuanAbsenNotification( string $nomorTujuan, string $namaAtasan, string $namaPemohon, string $nipPemohon, int $jumlahHari, array $daftarTanggal, string $keterangan, string $link ): bool { try { $response = Http::withToken($this->token) ->post("{$this->baseUrl}/api/v1/public/messages/send", [ 'phone_number' => $nomorTujuan, 'channel' => 'whatsapp', 'message_type' => 'template', 'template' => [ 'name' => 'verifikasi_presensi_wa', 'language' => ['code' => 'id'], 'components' => [ [ 'type' => 'body', 'parameters' => [ ['type' => 'text', 'text' => $namaAtasan], ['type' => 'text', 'text' => $namaPemohon], ['type' => 'text', 'text' => $nipPemohon], ['type' => 'text', 'text' => (string) $jumlahHari], ['type' => 'text', 'text' => $this->formatDaftarTanggal($daftarTanggal)], ['type' => 'text', 'text' => $keterangan], ], ], [ 'type' => 'button', 'sub_type' => 'url', 'index' => '0', 'parameters' => [ ['type' => 'text', 'text' => $link], ], ], ], ], ]); } catch (Throwable $th) { Log::error('WhatsApp sendPengajuanAbsenNotification : '.$th->getMessage()); return false; } if (! $response->successful()) { Log::error("WhatsApp sendPengajuanAbsenNotification gagal: HTTP {$response->status()} - {$response->body()}"); return false; } return true; } }