Попробуйте это
Код в контроллере
public function getview(Request $request)
{
$user=new User();
$anserone= $request->answerQuestionOne;
$anstwo = $request->answerQuestionTwo;
return view('auth.question',compact('user','anserone','anstwo'));
}
public function chekQuestions(Request $request)
{
$this->validate($request, [
'email' => 'required|string|email',
'answerQuestionOne' => 'required',
'answerQuestionTwo' => 'required'
]);
$user = User::where('email', $request->email)->first();
if ( $user == null) {
//
$user=new User();
$user->email= $request->email;
$anserone= $request->answerQuestionOne;
$anstwo = $request->answerQuestionTwo;
Session::flash('message', 'دا ایمل شتون نلری');
return view('auth.question',compact('user','anserone','anstwo'));
}
if ( $user->answerQuestionOne == null || $user->answerQuestionTwo == null) {
//
$user=new User();
$user->email= $request->email;
$anserone= $request->answerQuestionOne;
$anstwo = $request->answerQuestionTwo;
Session::flash('message4', 'هیڅ مورد نشته، لمړی تاسی خپل امنیتی ځوابونه خوندی کړی');
return view('auth.question',compact('user','anserone','anstwo'));
}
if ($user->answerQuestionOne != $request->answerQuestionOne) {
$anserone= $request->answerQuestionOne;
$anstwo = $request->answerQuestionTwo;
Session::flash('message2', 'دپښتنو ځوابونه مو ناسم وو');
return view('auth.question',compact('user','anserone','anstwo'));
}
if ( $user->answerQuestionTwo != $request->answerQuestionTwo) {
$anstwo = $request->answerQuestionTwo;
$anserone= $request->answerQuestionOne;
Session::flash('message3', 'دپښتنو ځوابونه مو ناسم وو');
return view('auth.question',compact('user','anstwo','anserone'));
}
return view('auth.updatePassword',compact('user'));
}
public function updagePassword(Request $request)
{
$this->validate($request, [
'email' => 'required|string|email',
'password' => 'required|min:8'
]);
// $user = User::first();
$user = User::where('email', $request->email)->first();
if ( $user == null) {
//
$user=new User();
$user->email= $request->email;
// $anserone= $request->answerQuestionOne;
// $anstwo = $request->answerQuestionTwo;
Session::flash('message', 'دا ایمل شتون نلری');
return view('auth.updatePassword',compact('user'));
}
if ($request->password_confirmation != $request->password) {
Session::flash('message3', 'پټ نوم مطابقت نلری');
return view('auth.updatePassword',compact('user'));
}
$user->where('email', $request->email)->update([
'password' => Hash::make($request->password)
]);
return redirect()->route('login');
}
**code in updatePassword.blade**
@extends('layouts.header')
<body class="login">
<div>
<a class="hiddenanchor" id="signup"></a>
<a class="hiddenanchor" id="signin"></a>
<a class="hiddenanchor" id="reset"></a>
<div class="login_wrapper">
<section class="login_content">
<form method="POST" action="{{route('update.question')}}" >
@csrf
<h3>د پټ نوم تازه کړی </h3>
<div class="form-group has-feedback">
<input id="email" type="email" placeholder=" ایمل" class="form-control "name="email" value="{{$user->email}}" required autocomplete="email" autofocus>
@if(Session::has('message'))
<p class="bg-danger">{{session('message')}} </p>
@endif
<div class="form-control-feedback">
<i class="fa fa-envelope-o text-muted"></i>
</div>
</div>
<div>
<input id="password" type="password" placeholder="پټ نوم" class="form-control" name="password" required minlength="8">
{{-- <input id="answerQuestionOne" placeholder="ځواب مو دلته ولیکی" type="text" class="form-control" name="answerQuestionOne" value="{{$anserone}}" required autocomplete="answerQuestionOne" autofocus> --}}
@if(Session::has('message2'))
<p class="bg-danger">{{session('message2')}} </p>
@endif
</div>
<div>
<input id="password-confirm" type="password" placeholder="دپټنوم تأیید " class="form-control" name="password_confirmation" minlength="4" required >
{{-- <input id="answerQuestionTwo" placeholder="ځواب مو دلته ولیکی " type="text" class="form-control " name="answerQuestionTwo" value="{{$anstwo}}" required autocomplete="answerQuestionTwo" autofocus> --}}
@if(Session::has('message3'))
<p class="bg-danger">{{session('message3')}} </p>
@endif
</div>
<button type="submit" class="btn btn-default btn-block">خوندی کړی </button>
<div class="clearfix"></div>
<div class="separator">
{{-- <p class="change_link">
<a href="#signin" class="to_register"> تاسو دمخه غړی یاست ننوتل </a>
</p> --}}
<div class="clearfix"></div>
<br />
</form>
</section>
</div>
{{-- reset password via email --}}
{{-- </div> --}}
</div>
</body>
</html>
**Code in question.blade**
@extends('layouts.header')
<body class="login">
<div>
<a class="hiddenanchor" id="signup"></a>
<a class="hiddenanchor" id="signin"></a>
<a class="hiddenanchor" id="reset"></a>
<div class="login_wrapper">
<section class="login_content">
<form method="POST" action="{{route('check.question')}}" >
@csrf
<h3>د پټ نو بیا راګرځولو لپاره لاندی امنیتی پوښتنو ته ځواب ورکړی </h3>
<div> @if(Session::has('message4'))
<h4 class="bg-danger">{{session('message4')}} </h4>
@endif</div>
<div class="form-group has-feedback">
<input id="email" type="email" placeholder=" ایمل" class="form-control "name="email" value="{{$user->email}}" required autocomplete="email" autofocus>
@if(Session::has('message'))
<p class="bg-danger">{{session('message')}} </p>
@endif
<div class="form-control-feedback">
<i class="fa fa-envelope-o text-muted"></i>
</div>
</div>
<div>
<select
style="margin-bottom:20px;width: 100%;padding: 7px; "
>
<option value selected>مهرباني وکړئ خپله لمومړنی امنيتي پوښتنه وټاکئ</option>
<option>ستا د خوښې رنګ کوم دی؟</option>
<option>تاسو په کوم ښار کې زیږیدلی یاست؟</option>
<option>ستا د خوښې خواړه څه دي؟</option>
<option>ستاسو د غوره ملګري لومړی نوم څه شی دی؟</option>
<option>کوم ورزش مو خوښ دی؟</option>
<option>ستاسو د خوښې سپورټ ټیم څه شی دی؟</option>
</select>
</div>
<div>
<input id="answerQuestionOne" placeholder="ځواب مو دلته ولیکی" type="text" class="form-control" name="answerQuestionOne" value="{{$anserone}}" required autocomplete="answerQuestionOne" autofocus>
@if(Session::has('message2'))
<p class="bg-danger">{{session('message2')}} </p>
@endif
</div>
<div>
<select style="margin-bottom:20px;width: 100%;padding: 7px; ">
<option value selected>مهرباني وکړئ خپله دوهمه امنيتي پوښتنه وټاکئ</option>
<option>ستا د خوښې رنګ کوم دی؟</option>
<option>تاسو په کوم ښار کې زیږیدلی یاست؟</option>
<option>ستا د خوښې خواړه څه دي؟</option>
<option>ستاسو د غوره ملګري لومړی نوم څه شی دی؟</option>
<option>کوم ورزش مو خوښ دی؟</option>
<option>ستاسو د خوښې سپورټ ټیم څه شی دی؟</option>
</select>
</div>
<div>
<input id="answerQuestionTwo" placeholder="ځواب مو دلته ولیکی " type="text" class="form-control " name="answerQuestionTwo" value="{{$anstwo}}" required autocomplete="answerQuestionTwo" autofocus>
@if(Session::has('message3'))
<p class="bg-danger">{{session('message3')}} </p>
@endif
</div>
<button type="submit" class="btn btn-default btn-block">خوندی کړی </button>
<div class="clearfix"></div>
<div class="separator">
{{-- <p class="change_link">
<a href="#signin" class="to_register"> تاسو دمخه غړی یاست ننوتل </a>
</p> --}}
<div class="clearfix"></div>
<br />
</form>
</section>
</div>
{{-- reset password via email --}}
{{-- </div> --}}
</div>
</body>
</html>