如何在 laravel 5.2 中验证电话号码?[已关闭]
2022-08-30 08:49:50
我想验证用户输入的电话号码,其中数字应正好是11,并以01开头,值字段应仅为数字。如何使用Laravel验证进行验证?
这是我的控制器:
public function saveUser(Request $request){
$this->validate($request,[
'name' => 'required|max:120',
'email' => 'required|email|unique:users',
'phone' => 'required|min:11|numeric',
'course_id'=>'required'
]);
$user = new User();
$user->name= $request->Input(['name']);
$user->email= $request->Input(['email']);
$user->phone= $request->Input(['phone']);
$user->date = date('Y-m-d');
$user->completed_status = '0';
$user->course_id=$request->Input(['course_id']);
$user->save();
return redirect('success');
}