fix: pre-fill phone_number_id on new company from existing shared value
All companies use the same WhatsApp phone number ID. When creating a new company, auto-fill the field with the value already in use so the admin doesn't have to look it up and type it manually. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
1f8af616c5
commit
68317da748
@@ -989,10 +989,17 @@ HTML;
|
||||
$isEdit = $id > 0;
|
||||
$company = $isEdit ? CompanyRepository::findById($id) : null;
|
||||
|
||||
// For new companies, default phone_number_id to the shared value already in use
|
||||
$defaultPhoneNumberId = '';
|
||||
if (!$isEdit) {
|
||||
$r = db()->query("SELECT phone_number_id FROM companies WHERE phone_number_id != '' LIMIT 1")->fetch();
|
||||
$defaultPhoneNumberId = $r ? (string)$r['phone_number_id'] : env('WHATSAPP_DEFAULT_PHONE_NUMBER_ID', '');
|
||||
}
|
||||
|
||||
$cv = fn(string $k, string $d = '') => self::h($company[$k] ?? $d);
|
||||
$name = $cv('name');
|
||||
$display_name = $cv('display_name');
|
||||
$phone_number_id = $cv('phone_number_id');
|
||||
$phone_number_id = $isEdit ? $cv('phone_number_id') : self::h($defaultPhoneNumberId);
|
||||
$display_phone = $cv('display_phone');
|
||||
$api_base_url = $cv('api_base_url');
|
||||
$api_key = $cv('api_key');
|
||||
|
||||
Reference in New Issue
Block a user