ifnex/04_Laravel/update_calling_codes.php
Kazem Alghasi a1a6dbdd8a feat(core): complete phase 3 integration and enhance country/phone features
This commit marks the completion of Phase 3 (Integration and Improvements) and updates the project status to reflect that Phases 0 through 3 are finished.

Key changes include:
- **Laravel (Backend):**
  - Added `calling_code` column to `countries` table via new migration.
  - Added scripts to update calling codes for all countries.
  - Updated `CustomerOrderController` to include `calling_code` in country data.
  - Registered `api_key` middleware alias in `bootstrap/app.php`.
  - Improved error handling to return JSON 401 for API authentication failures.
  - Updated `README.md` with detailed architecture and feature descriptions.
- **WordPress (Frontend/Bridge):**
  - Added `ifnex_wallet_charge` shortcode and AJAX handler for wallet top-ups.
  - Implemented auto-fill for calling codes in the order form based on selected country.
  - Added real-time phone number validation (digits, +, spaces only).
  - Added English-only validation for name, city, and address fields with UI warnings.
  - Updated asset enqueuing logic and versioning for CSS/JS.
- **Documentation:**
  - Updated `IFNEX_File_Map.md`, `IFNEX_Phase0_Checklist.md`, and `IFNEX_Roadmap.md` to reflect completed phases and new features.
  - Updated `DEPLOYMENT.md` with new environment variables (`IFNEX_BRIDGE_API_KEY`) and required WordPress pages.
  - Updated project `README.md` with comprehensive feature list and system architecture.
2026-08-29 04:38:28 +03:30

28 lines
1.1 KiB
PHP

<?php
$map = [
'IR' => '+98', 'AE' => '+971', 'AF' => '+93', 'AL' => '+355', 'AM' => '+374',
'AZ' => '+994', 'BH' => '+973', 'BY' => '+375', 'CN' => '+86', 'DE' => '+49',
'FR' => '+33', 'GB' => '+44', 'IN' => '+91', 'IQ' => '+964', 'KG' => '+996',
'KW' => '+965', 'KZ' => '+7', 'LB' => '+961', 'NL' => '+31', 'OM' => '+968',
'PK' => '+92', 'PS' => '+970', 'QA' => '+974', 'RU' => '+7', 'SA' => '+966',
'SY' => '+963', 'TJ' => '+992', 'TR' => '+90', 'TM' => '+993', 'UA' => '+380',
'US' => '+1', 'UZ' => '+998',
];
require __DIR__ . '/vendor/autoload.php';
$app = require_once __DIR__ . '/bootstrap/app.php';
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
use App\Models\Country;
$updated = 0;
foreach ($map as $iso => $code) {
$cnt = Country::where('iso_code', $iso)->update(['calling_code' => $code]);
if ($cnt > 0) {
$updated += $cnt;
echo "Updated {$iso} => {$code}\n";
}
}
echo "\nDone. Total updated: {$updated}\n";
echo "Countries with calling_code: " . Country::whereNotNull('calling_code')->count() . "\n";