<?php namespace App\Http\Controllers; use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\{Hash,Password}; use Illuminate\Auth\Events\PasswordReset; use Illuminate\Support\Str; class PasswordController extends Controller {public function forgot(){return view('auth.forgot-password');}public function email(Request $r){$r->validate(['email'=>'required|email']);$status=Password::sendResetLink($r->only('email'));return back()->with('success',__($status));}public function resetForm(Request $r,string $token){return view('auth.reset-password',['token'=>$token,'email'=>$r->email]);}public function reset(Request $r){$d=$r->validate(['token'=>'required','email'=>'required|email','password'=>'required|min:12|confirmed']);$status=Password::reset($d,function(User $u,string $password){$u->forceFill(['password'=>Hash::make($password),'remember_token'=>Str::random(60)])->save();event(new PasswordReset($u));});return $status===Password::PASSWORD_RESET?redirect()->route('login')->with('success',__($status)):back()->withErrors(['email'=>__($status)]);}}