mmae/phones
最新稳定版本:1.0.0
Composer 安装命令:
composer require mmae/phones
包简介
Phone class that make dealing with phone numbers easy
README 文档
README
laravel package to make interact with phone number easier
1. Supported Countries
* Egypt (EG)
* Soudi Arabia (KSA)
* Lybia (LY)
* Qtar (QT)
* Oman (OM)
* Arab Emirates (AU)
* Bahrain (BH)
* kwit (KW)
2. Installation
composer require mmae/phones
3. Usage
- validate the number before saving the record
<?php use Illuminate\Http\Request; use MMAE\Phones\EGPhone; class UserController extends App\Http\Controllers\Controller { function store(Request $request) { $data = $request->validate([ 'name' => 'required' 'phone' = 'required' ]) $phone = EGPhone::make($data['phone']); if ($phone->isNotValid()){ return back()->withErrors([ 'phone' => 'wrong format' ]) } $data ['name'] = $phone; // if you save the full version of the number \App\Models\User::create($data); return back()->with('success','created') } }
- validate the number before sending sms if you supporting multiple country registration
$phone = \MMAE\Phones\Phone::make($user->phone, $user->country_code)
if($phone->isNotValid()){
throw new Exception('wrong format')
}
$SMSService ->message('hello')->to($phone->withPlus())->send()
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-12