Laravel 手机号码字段的唯一验证
我正在数据库中插入一个手机号码,我想创建一个唯一的验证作为电子邮件字段。它无法为我的控制器运行。需要改变 控制器:Laravel 手机号码字段的唯一验证,laravel,Laravel,我正在数据库中插入一个手机号码,我想创建一个唯一的验证作为电子邮件字段。它无法为我的控制器运行。需要改变 控制器: $this->validate($req, [ 'client_name' =>'required', 'email'=>'required|unique:table_client_registration', 'mobileno'=>'numeric|unique:table_client_regi
$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>
刀片:
$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>
@如果($errors->has('mobileno'))*{{{$errors->first('mobileno')}}
@endif
您的字段名是mobile
,您正在尝试验证mobileno
因此,要么在您的视图中将其更改为:
<input type="text" name="mobileno" class="form-control" placeholder="Enter Mobile No">