diff --git a/app/Http/Controllers/Students/ProfileController.php b/app/Http/Controllers/Students/ProfileController.php index 5ccf535..edf964c 100644 --- a/app/Http/Controllers/Students/ProfileController.php +++ b/app/Http/Controllers/Students/ProfileController.php @@ -5,6 +5,7 @@ use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Models\Student; +use Illuminate\Support\Facades\Hash; class ProfileController extends Controller { @@ -45,6 +46,29 @@ public function save_profile(Request $request) } } + public function change_password(Request $request) + { + try { + $data = Student::find(currentUserId()); + + // Validate current password + if (!Hash::check($request->current_password, $data->password)) { + return redirect()->back()->with('error', 'Current password is incorrect.'); + } + + $data->password = Hash::make($request->password); + $data->language = 'en'; + + if ($data->save()) { + $this->setSession($data); + return redirect()->back()->with('success', 'Data Saved'); + } + } catch (Exception $e) { + // dd($e); + return redirect()->back()->withInput()->with('error', 'Please try again'); + } + } + public function setSession($student) { return request()->session()->put( diff --git a/public/uploads/students/2931702880014.png b/public/uploads/students/2931702880014.png new file mode 100644 index 0000000..1d46e96 Binary files /dev/null and b/public/uploads/students/2931702880014.png differ diff --git a/resources/views/students/Auth/register.blade.php b/resources/views/students/Auth/register.blade.php index cbb0914..95ee1eb 100644 --- a/resources/views/students/Auth/register.blade.php +++ b/resources/views/students/Auth/register.blade.php @@ -74,7 +74,7 @@
+ class="img-fluid" />