A package for Myanmar tools which extend Laravel’s core.
- Installation
- Version Compatibilities
- Documentation
- Str
- Request
- Collection
- Validation
- Version History
- Credits
composer require pyaesoneaung/laravel-myanmar-tools
Laravel Myanmar Tools | Laravel 9.* | Laravel 8.* | Laravel 7.* | Laravel 6.* |
---|---|---|---|---|
2.x | ✅ | ✅ | ✅ | ✅ |
1.x | ✅ | ❌ | ❌ | ❌ |
Read the full documentation at laravel-myanmar-tools.com
use Illuminate\Support\Str;
Str::isUnicodeFont('မြန်မာပြည်'); // return true
use Illuminate\Support\Str;
Str::isZawgyiFont('ျမန္မာျပည္'); // return true
use Illuminate\Support\Str;
Str::detectMyanmarFont('မြန်မာပြည်'); // return 'unicode'
Str::detectMyanmarFont('ျမန္မာျပည္'); // return 'zawgyi'
use Illuminate\Support\Str;
Str::zgToUni('ျမန္မာျပည္'); // return 'မြန်မာပြည်'
use Illuminate\Support\Str;
Str::uniToZg('မြန်မာပြည်'); // return 'ျမန္မာျပည္'
use Illuminate\Support\Str;
Str::isMyanmarPhoneNumber('09250000000'); // return true
use Illuminate\Support\Str;
Str::isMpt('09250000000'); // return true
use Illuminate\Support\Str;
Str::isOoredoo('09970000000'); // return true
use Illuminate\Support\Str;
Str::isTelenor('09790000000'); // return true
use Illuminate\Support\Str;
Str::isMec('0930000000'); // return true
use Illuminate\Support\Str;
Str::isMytel('09690000000'); // return true
use Illuminate\Support\Str;
Str::telecomName('09250000000'); // return 'mpt'
Str::telecomName('09970000000'); // return 'ooredoo'
Str::telecomName('09790000000'); // return 'telenor'
Str::telecomName('0930000000'); // return 'mec'
Str::telecomName('09690000000'); // return 'mytel'
use Illuminate\Support\Str;
Str::normalizeMyanmarPhoneNumber('09250000000'); // return '09250000000'
Str::normalizeMyanmarPhoneNumber('(၀၉)၂၅၀၀၀၀၀၀၀'); // return '09250000000'
Str::normalizeMyanmarPhoneNumber('၀၉-၂၅၀၀၀၀၀၀၀'); // return '09250000000'
Str::normalizeMyanmarPhoneNumber('+၉၅၉၂၅၀၀၀၀၀၀၀'); // return '09250000000'
Str::normalizeMyanmarPhoneNumber('09-၂၅ဝရဝရဝရဝ');
// return '09250707070' (ဝလုံး နဲ့ ရကောက် ပါလျှင် 0 နဲ့ 7 လို့ပြောင်းလဲပါသည်)
// https://domain/path?name=မြန်မာပြည်
$request->isUnicodeFont('name'); // return true
// https://domain/path?name=ျမန္မာျပည္
$request->isZawgyiFont('name'); // return true
// https://domain/path?name=မြန်မာပြည်
$request->detectMyanmarFont('name'); // return 'unicode'
// https://domain/path?name=ျမန္မာျပည္
$request->detectMyanmarFont('name'); // return 'zawgyi'
// https://domain/path?name=ျမန္မာျပည္
$request->zgToUni('name'); // return 'မြန်မာပြည်'
// https://domain/path?name=မြန်မာပြည်
$request->uniToZg('name'); // return 'ျမန္မာျပည္'
// https://domain/path?phone=09250000000
$request->isMyanmarPhoneNumber('phone'); // return true
// https://domain/path?phone=09250000000
$request->isMpt('phone'); // return true
// https://domain/path?phone=09970000000
$request->isOoredoo('phone'); // return true
// https://domain/path?phone=09790000000
$request->isTelenor('phone'); // return true
// https://domain/path?phone=0930000000
$request->isMec('phone'); // return true
// https://domain/path?phone=09690000000
$request->isMytel('phone'); // return true
// https://domain/path?phone=09250000000
$request->telecomName('phone'); // return 'mpt'
// https://domain/path?phone=09970000000
$request->telecomName('phone'); // return 'ooredoo'
// https://domain/path?phone=09790000000
$request->telecomName('phone'); // return 'telenor'
// https://domain/path?phone=0930000000
$request->telecomName('phone'); // return 'mec'
// https://domain/path?phone=09690000000
$request->telecomName('phone'); // return 'mytel'
// https://domain/path?phone=09250000000
$request->normalizeMyanmarPhoneNumber('phone'); // return '09250000000'
// https://domain/path?phone=(၀၉)၂၅၀၀၀၀၀၀၀
$request->normalizeMyanmarPhoneNumber('phone'); // return '09250000000'
// https://domain/path?phone=၀၉-၂၅၀၀၀၀၀၀၀
$request->normalizeMyanmarPhoneNumber('phone'); // return '09250000000'
// https://domain/path?phone=+၉၅၉၂၅၀၀၀၀၀၀၀
$request->normalizeMyanmarPhoneNumber('phone'); // return '09250000000'
// https://domain/path?phone=09-၂၅ဝရဝရဝရဝ
$request->normalizeMyanmarPhoneNumber('phone');
// return '09250707070' (ဝလုံး နဲ့ ရကောက် ပါလျှင် 0 နဲ့ 7 လို့ပြောင်းလဲပါသည်)
$data = ['09250000000', 'abc'];
collect($data)->whereMyanmarPhoneNumber()->toArray();
// ['09250000000']
$data = [
['phone' => '09250000000'],
['phone' => 'abc']
];
collect($data)->whereMyanmarPhoneNumber('phone')->toArray();
/*
[
['phone' => '09250000000']
]
*/
$data = [
['user' => ['phone' => '09250000000']],
['user' => ['phone' => 'abc']],
];
collect($data)->whereMyanmarPhoneNumber('user.phone')->toArray();
/*
[
['user' => ['phone' => '09250000000']],
]
*/
$data = ['09250000000', '09970000000'];
collect($data)->whereMpt()->toArray();
// ['09250000000']
$data = [
['phone' => '09250000000'],
['phone' => '09970000000']
];
collect($data)->whereMpt('phone')->toArray();
/*
[
['phone' => '09250000000']
]
*/
$data = [
['user' => ['phone' => '09250000000']],
['user' => ['phone' => '09970000000']],
];
collect($data)->whereMpt('user.phone')->toArray();
/*
[
['user' => ['phone' => '09250000000']],
]
*/
$data = ['09250000000', '09970000000'];
collect($data)->whereOoredoo()->toArray();
// ['09970000000']
$data = [
['phone' => '09250000000'],
['phone' => '09970000000']
];
collect($data)->whereOoredoo('phone')->toArray();
/*
[
['phone' => '09970000000']
]
*/
$data = [
['user' => ['phone' => '09250000000']],
['user' => ['phone' => '09970000000']],
];
collect($data)->whereOoredoo('user.phone')->toArray();
/*
[
['user' => ['phone' => '09970000000']],
]
*/
$data = ['09250000000', '09790000000'];
collect($data)->whereTelenor()->toArray();
// ['09790000000']
$data = [
['phone' => '09250000000'],
['phone' => '09790000000']
];
collect($data)->whereTelenor('phone')->toArray();
/*
[
['phone' => '09790000000']
]
*/
$data = [
['user' => ['phone' => '09250000000']],
['user' => ['phone' => '09790000000']],
];
collect($data)->whereTelenor('user.phone')->toArray();
/*
[
['user' => ['phone' => '09790000000']],
]
*/
$data = ['09250000000', '0930000000'];
collect($data)->whereMec()->toArray();
// ['0930000000']
$data = [
['phone' => '09250000000'],
['phone' => '0930000000']
];
collect($data)->whereMec('phone')->toArray();
/*
[
['phone' => '0930000000']
]
*/
$data = [
['user' => ['phone' => '09250000000']],
['user' => ['phone' => '0930000000']],
];
collect($data)->whereMec('user.phone')->toArray();
/*
[
['user' => ['phone' => '0930000000']],
]
*/
$data = ['09250000000', '09690000000'];
collect($data)->whereMytel()->toArray();
// ['09690000000']
$data = [
['phone' => '09250000000'],
['phone' => '09690000000']
];
collect($data)->whereMytel('phone')->toArray();
/*
[
['phone' => '09690000000']
]
*/
$data = [
['user' => ['phone' => '09250000000']],
['user' => ['phone' => '09690000000']],
];
collect($data)->whereMytel('user.phone')->toArray();
/*
[
['user' => ['phone' => '09690000000']],
]
*/
$data = ['မြန်မာပြည်'];
collect($data)->uniToZg()->toArray();
// ['ျမန္မာျပည္']
$data = [
['name' => 'မြန်မာပြည်']
];
collect($data)->uniToZg('name')->toArray();
/*
[
['name' => 'ျမန္မာျပည္']
]
*/
$data = [
['user' => ['name' => 'မြန်မာပြည်']]
];
collect($data)->uniToZg('user.name')->toArray();
/*
[
['user' => ['name' => 'ျမန္မာျပည္']]
]
*/
$data = ['ျမန္မာျပည္'];
collect($data)->zgToUni()->toArray();
// ['မြန်မာပြည်']
$data = [
['name' => 'ျမန္မာျပည္']
];
collect($data)->zgToUni('name')->toArray();
/*
[
['name' => 'မြန်မာပြည်']
]
*/
$data = [
['user' => ['name' => 'ျမန္မာျပည္']]
];
collect($data)->zgToUni('user.name')->toArray();
/*
[
['user' => ['name' => 'မြန်မာပြည်']]
]
*/
$request->validate([
'phone' => ['required', 'myanmarPhoneNumber'],
]);
$request->validate([
'phone' => ['required', 'mpt'],
]);
$request->validate([
'phone' => ['required', 'ooredoo'],
]);
$request->validate([
'phone' => ['required', 'telenor'],
]);
$request->validate([
'phone' => ['required', 'mec'],
]);
$request->validate([
'phone' => ['required', 'mytel'],
]);
php artisan vendor:publish --provider="PyaeSoneAung\LaravelMyanmarTools\LaravelMyanmarToolsServiceProvider"
You can edit the error messages at /lang/vendor/laravelMyanmarTools/en/validation.php
return [
'myanmar_phone_number' => 'The :attribute must be valid myanmar phone number.',
'mpt' => 'The :attribute must be valid MPT number.',
'ooredoo' => 'The :attribute must be valid Ooredoo number.',
'telenor' => 'The :attribute must be valid Telenor number.',
'mec' => 'The :attribute must be valid MEC number.',
'mytel' => 'The :attribute must be valid Mytel number.',
];
- 2.2.1
- bug fixed publishing translations
- 2.2.0
- added normalizeMyanmarPhoneNumber request macro
- 2.1.0
- added normalizeMyanmarPhoneNumber str macro
- 2.0.0
- support laravel 9.* | 8.* | 7.* | 6.* 🎉
- 1.4.1
- bug fixed collection macros (uniToZg and zgToUni)
- 1.4.0
- extended phone number validation
- 1.3.0
- improved collection macros
- changed request macros usage
- 1.2.0
- added collection macros
- improved zawgyi detection
- 1.1.0
- added request macros
- 1.0.0
- initial release