<?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