1. Go to this page and download the library: Download propaganistas/laravel-phone 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/ */
propaganistas / laravel-phone example snippets
'phone' => 'The :attribute field must be a valid number.',
'phonefield' => 'phone:US,BE',
// 'phonefield' => (new Phone)->country(['US', 'BE'])
'phonefield' => 'phone:INTERNATIONAL,BE',
// 'phonefield' => (new Phone)->international()->country('BE')
'phonefield' => 'phone:mobile',
// 'phonefield' => (new Phone)->type('mobile')
'phonefield' => 'phone:!mobile',
// 'phonefield' => (new Phone)->notType('mobile')
'phonefield' => 'phone:LENIENT',
// 'phonefield' => (new Phone)->lenient()
use Illuminate\Database\Eloquent\Model;
use Propaganistas\LaravelPhone\Casts\RawPhoneNumberCast;
use Propaganistas\LaravelPhone\Casts\E164PhoneNumberCast;
class User extends Model
{
public $casts = [
'phone_1' => RawPhoneNumberCast::class.':BE',
'phone_2' => E164PhoneNumberCast::class.':BE',
];
}
use Propaganistas\LaravelPhone\PhoneNumber;
(string) new PhoneNumber('+3212/34.56.78'); // +3212345678
(string) new PhoneNumber('012 34 56 78', 'BE'); // +3212345678
$phone = new PhoneNumber('012/34.56.78', 'BE');
$phone->format($format); // See libphonenumber\PhoneNumberFormat
$phone->formatE164(); // +3212345678
$phone->formatInternational(); // +32 12 34 56 78
$phone->formatRFC3966(); // tel:+32-12-34-56-78
$phone->formatNational(); // 012 34 56 78
// Formats so the number can be called straight from the provided country.
$phone->formatForCountry('BE'); // 012 34 56 78
$phone->formatForCountry('NL'); // 00 32 12 34 56 78
$phone->formatForCountry('US'); // 011 32 12 34 56 78
// Formats so the number can be clicked on and called straight from the provided country using a cellphone.
$phone->formatForMobileDialingInCountry('BE'); // 012345678
$phone->formatForMobileDialingInCountry('NL'); // +3212345678
$phone->formatForMobileDialingInCountry('US'); // +3212345678