PHP code example of cheesegrits / filament-phone-numbers

1. Go to this page and download the library: Download cheesegrits/filament-phone-numbers library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cheesegrits / filament-phone-numbers example snippets


return [
    'defaults' => [
        'region' => env('FILAMENT_PHONE_NUMBERS_ISO_COUNTRY', 'US'),
        'database_format' => env('FILAMENT_PHONE_NUMBERS_DATABASE_FORMAT', PhoneNumberFormat::E164),
        'display_format' => env('FILAMENT_PHONE_NUMBERS_DISPLAY_FORMAT', PhoneNumberFormat::NATIONAL),
        'icon' => env('FILAMENT_PHONE_NUMBERS_ICON', 'heroicon-m-phone'),
    ],
];

use Cheesegrits\FilamentPhoneNumbers;

FilamentPhoneNumbers\Forms\Components\PhoneNumber::make('phone')

use Cheesegrits\FilamentPhoneNumbers;

FilamentPhoneNumbers\Forms\Components\PhoneNumber::make('phone')
    ->displayFormat(FilamentPhoneNumbers\Enums\PhoneFormat::INTERNATIONAL)
    ->databaseFormat(FilamentPhoneNumbers\Enums\PhoneFormat::INTERNATIONAL)

use Cheesegrits\FilamentPhoneNumbers;

FilamentPhoneNumbers\Forms\Components\PhoneNumber::make('phone')
    ->strict()

use Cheesegrits\FilamentPhoneNumbers;

FilamentPhoneNumbers\Forms\Components\PhoneNumber::make('phone')
    ->region('GB')

use Cheesegrits\FilamentPhoneNumbers;

FilamentPhoneNumbers\Forms\Components\PhoneNumber::make('phone')
    ->mask('99 99-99-99-99')

use Cheesegrits\FilamentPhoneNumbers;

FilamentPhoneNumbers\Columns\PhoneNumberColumn::make('phone'),

use Cheesegrits\FilamentPhoneNumbers;

FilamentPhoneNumbers\Columns\PhoneNumberColumn::make('phone')
    ->displayFormat(FilamentPhoneNumbers\Enums\PhoneFormat::NATIONAL)
    ->region('CA')
    ->dial(),

use Cheesegrits\FilamentPhoneNumbers;
use Illuminate\Database\Query\Builder;

// uses modified search query described above
FilamentPhoneNumbers\Columns\PhoneNumberColumn::make('phone')
    ->searchable(),

// bypasses query modification to use standard Filament query
FilamentPhoneNumbers\Columns\PhoneNumberColumn::make('phone')
    ->useDefaultSearch()
    ->searchable(),

// uses your own query, bypassing custom query
FilamentPhoneNumbers\Columns\PhoneNumberColumn::make('phone')
    ->searchable(query: function (Builder $query, string $search) { 
        // your query here
    }),

use Cheesegrits\FilamentPhoneNumbers;

FilamentPhoneNumbers\Infolists\Components\PhoneNumberEntry::make('phone'),

use Cheesegrits\FilamentPhoneNumbers;

FilamentPhoneNumbers\Infolists\Components\PhoneNumberEntry::make('phone')
    ->displayFormat(FilamentPhoneNumbers\Enums\PhoneFormat::INTERNATIONAL)
    ->region('GB')
    ->dial(),
bash
php artisan vendor:publish --tag="filament-phone-numbers-config"
sh
php artisan filament-phone-numbers:normalize
shell
php artisan filament-phone-numbers:normalize --commit
shell
php artisan filament-phone-numbers:normalize --commit --delete-invalid