Commit c2683d48 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fix TypeError: WhatsApp config returns null when env vars are unset

Cast config values to string with null-coalescing fallback, and add
empty-string defaults to env() calls so instances without WhatsApp
configured still boot without TypeError.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 77f7d4a2
...@@ -17,9 +17,9 @@ class WhatsAppService ...@@ -17,9 +17,9 @@ class WhatsAppService
public function __construct() public function __construct()
{ {
$this->apiVersion = config('services.whatsapp.api_version', 'v25.0'); $this->apiVersion = (string) (config('services.whatsapp.api_version') ?? 'v25.0');
$this->phoneNumberId = config('services.whatsapp.phone_number_id', ''); $this->phoneNumberId = (string) (config('services.whatsapp.phone_number_id') ?? '');
$this->accessToken = config('services.whatsapp.access_token', ''); $this->accessToken = (string) (config('services.whatsapp.access_token') ?? '');
$this->baseUrl = "https://graph.facebook.com/{$this->apiVersion}/{$this->phoneNumberId}"; $this->baseUrl = "https://graph.facebook.com/{$this->apiVersion}/{$this->phoneNumberId}";
} }
......
...@@ -37,9 +37,9 @@ ...@@ -37,9 +37,9 @@
'whatsapp' => [ 'whatsapp' => [
'api_version' => env('WHATSAPP_API_VERSION', 'v25.0'), 'api_version' => env('WHATSAPP_API_VERSION', 'v25.0'),
'phone_number_id' => env('WHATSAPP_PHONE_NUMBER_ID'), 'phone_number_id' => env('WHATSAPP_PHONE_NUMBER_ID', ''),
'access_token' => env('WHATSAPP_ACCESS_TOKEN'), 'access_token' => env('WHATSAPP_ACCESS_TOKEN', ''),
'webhook_verify_token' => env('WHATSAPP_WEBHOOK_VERIFY_TOKEN'), 'webhook_verify_token' => env('WHATSAPP_WEBHOOK_VERIFY_TOKEN', ''),
], ],
]; ];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment