I am getting this error in PHP Laravel while accessing data in blade.
Use of undefined constant user_id - assumed 'user_id' (this will throw an Error in a future version of PHP) (View: /home/beatsbaj/public_html/resources/views/user/reset-password.blade.php)
#Here is My Controller's function
public function resetPassword()
{
try
{
$token_id = Crypt::decrypt(Request::segment(2));
$token = Crypt::decrypt(Request::segment(3));
$data = Remembertoken::select('id', 'token_id', 'token', 'user_id')->where('token_id', $token_id)->get()->first();
if(!$data)
{
return abort(404);
}
else if($data)
{
if($data->token != $token)
{
return abort(404);
}
else if($data->token == $token)
{
return view('user.reset-password', ["token_id"=>$token_id, "user_id"=>$data->user_id]);
}
}
}
catch(\Exception $e)
{
abort(404);
}
}
My Ajax part in blade when I am accessing user_id variable.
<script>
$(document).ready(function(){
$("#reset-pass-form").submit(function(event) {
event.preventDefault();
var form = $(this);
form = form.serialize(form);
$.ajax({
url:"{{url('/reset-password-now')}}",
type:"post",
data:form,
success:function(response){
console.log(response);
console.log("{{user_id}}"); // Getting Error Here
},
error:function(xhr, ajaxOptions, thrownError){
alert(xhr.status);
},
});
});
});
</script>