Route:
Route::match(['get','post'],'/ validate/restraunt-email','bac kEnd\AuthController@check_admi n_email');
Controller :
public function check_admin_email(){
$email = $_GET['email'];
$user_id = $_GET['user'];
$check = Admin::where('email',$email)-> where('id','<>',$user_id)->cou nt();
if($check>0){
return 'false';
} else{
return 'true';
}
}
$email = $_GET['email'];
$user_id = $_GET['user'];
$check = Admin::where('email',$email)->
if($check>0){
return 'false';
} else{
return 'true';
}
}
Blade File:
<div class="form-group row">
<label class="col-sm-3 text-right control-label col-form-label">Email:</label>
<div class="col-sm-7">
<input type="email" class="form-control" id="" placeholder="Email" name="email" value="{{ isset($restraunt_data['email'] )? $restraunt_data['email']: old('email') }}">
</div>
</div>
<label class="col-sm-3 text-right control-label col-form-label">Email:</label>
<div class="col-sm-7">
<input type="email" class="form-control" id="" placeholder="Email" name="email" value="{{ isset($restraunt_data['email']
</div>
</div>
Validation Page Of Js
validate.js
$(document).ready(function(){
var server = window.location.protocol+'//'+ window.location.hostname+'/Qui cktapp';
$('#RestaurantsForm').validate ({
rules:{
first_name:{
required:true,
minlength:2,
maxlength:255,
regex:/^[a-zA-z ]+$/
},
last_name:{
required:true,
minlength:2,
maxlength:255,
regex:/^[a-zA-z ]+$/
},
email:{
required:true,
email:true,
maxlength:255,
remote:{
url: server+"/admin/validate/restra unt-email",
data:{
user:function(){
return $('#user').val();
},
},
},
},
phone_number:{
required:true,
digits:true,
minlength:5,
maxlength:15,
remote:{
url:server+"/admin/validate/re straunt-contact",
data:{
user:function(){
return $('#user').val();
},
},
},
},
status:{
required:true,
},
},
messages:{
email:{
remote:"This email-id is already registered"
},
phone_number:{
remote:"This contact number is already registered"
},
},
submitHandler:function(form){
form.submit();
},
});
var server = window.location.protocol+'//'+
$('#RestaurantsForm').validate
rules:{
first_name:{
required:true,
minlength:2,
maxlength:255,
regex:/^[a-zA-z ]+$/
},
last_name:{
required:true,
minlength:2,
maxlength:255,
regex:/^[a-zA-z ]+$/
},
email:{
required:true,
email:true,
maxlength:255,
remote:{
url: server+"/admin/validate/restra
data:{
user:function(){
return $('#user').val();
},
},
},
},
phone_number:{
required:true,
digits:true,
minlength:5,
maxlength:15,
remote:{
url:server+"/admin/validate/re
data:{
user:function(){
return $('#user').val();
},
},
},
},
status:{
required:true,
},
},
messages:{
email:{
remote:"This email-id is already registered"
},
phone_number:{
remote:"This contact number is already registered"
},
},
submitHandler:function(form){
form.submit();
},
});
Note: $user_id = $_GET['user'];
This is your blade page and you keep this id like this
<input type="text" id="user" name="user" value="your current id" >
0 Comments