I think something like this must do the job!
public function checkUserNameAvailability(Request $request){
$user_exists = (count(\App\User::where('username', '=', $request->input('user_name'))->get()) > 0) ? true : false;
return response()->json(['is_available' => $user_exists]);
}
Hi bro, Thanks for your reply but i can't implement this one. can you help me?
#in RegisterController
public function checkUserNameAvailability(Request $request){
$user_exists = (count(\App\User::where('user_name', '=', $request->input('user_name'))->get()) > 0) ? true : false;
return response()->json(['is_available' => $user_exists]);
}
in routs ->web.php
Route::get('/checkUserNameAvailability', 'Auth\RegisterController@checkUserNameAvailability')->name('checkUserName');
in jquery remote method validation
remote: {
type: 'GET',
url: '/checkUserName',
data: {
username: function ()
{
return $("input[name='user_name']").val();
}
},
async:false
//delay: 1000
}
what mistaken i did here..? Please help me.. Thanks in advance!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community