หลังจากที่ copy form update info admin มาใช้ เราก็ต้องมาเปลี่ยน route เพิ่ม
public function AdminUpdatePassword(Request $request){
// Validation
$request->validate([
‘old_password’ => ‘required’,
‘new_password’ => ‘required|confirmed’
]);
// Check if old password matches
if (!Hash::check($request->old_password, auth()->user()->password)) {
$notification = array(
‘message’ => ‘Old Password Does not Match!’,
‘alert-type’ => ‘error’
);
return back()->with($notification);
}
// Update the new password
User::whereId(auth()->user()->id)->update([
‘password’ => Hash::make($request->new_password)
]);
$notification = array(
‘message’ => ‘Password changed successfully!’,
‘alert-type’ => ‘success’
);
return back()->with($notification);
} // end Method
จากนั้นก็ลอง test ดู เย้! วันนี้คุณทำเสร็จแล้ว

test-chg-pwd

แบ่งปันกัน เราอยู่กันไม่เกิน 100 ปีหรอกครับ
สุดท้ายก็ทิ้งไว้ที่โลก จะคงเหลือไว้แต่คุณงามความดีที่ให้ระลึกถึงกันครับ
Follow Us / Thanat Sirikitphattana