我要在数据库中插入一个手机号码,并且想创建唯一的验证作为电子邮件字段。无法为我的控制器运行。需要更改
控制器:
$this->validate($req,
[
'client_name' =>'required',
'email'=>'required|unique:table_client_registration',
'mobileno'=>'numeric|unique:table_client_registration',
'password'=>'required',
'cpassword'=>'required|same:password'
],
$messages);
刀片:
<div class="row mt-3">
<div class="col">
<input type="text" name="mobile" class="form-control" placeholder="Enter Mobile No">
@if ($errors->has('mobileno')) <p style="color:red;">*{{ $errors->first('mobileno') }}</p> @endif
</div>
</div>
答案 0 :(得分:1)
您的字段名称为mobile
,而您正在尝试验证mobileno
..
因此,您可以将其更改为此:
<input type="text" name="mobileno" class="form-control" placeholder="Enter Mobile No">
或在您的验证中
$this->validate($req,
[
'client_name' =>'required',
'email'=>'required|unique:table_client_registration',
'mobile'=>'numeric|unique:table_client_registration',
'password'=>'required',
'cpassword'=>'required|same:password'
],
$messages);