Laravel 5.2 User Settings

Posted In PHP
  • mochinbn-bounouara 2 years ago

    Please can help me to add User Settings, specialy change password in laravel 5.2 ??

  • tnylea 2 years ago

    Hey Mochinbn-bounouara,

    Do you already have a form where the user can update their settings.

    I know one easy way you can do this is to set the password to only reset if it has changed. So, in your function you would do something like the following: 

    <?php
    
    public function update($request, $id){
        // Perform your validation
    
        $user = User::find($id);  
    
        if ($request->password == '') {
            $request->password = $user->password;
        } else {
            $request->password = Hash::make($request->password);
        }
    
        $user->update($request);
    
        // return back to route letting user know that they have successfully updated their account.
    
    }

    Let me know if that helps or if you need further assistance :)

Please login or signup to leave a response.

Login

or Sign Up

Sign Up

or Login
×
tnylea
Cheers Friend!

I'm Tony, the creator of this site. I'm trying to increase my twitter following. Want to follow me?

Follow @tnylea If not, no worries :)