public function update()
    {
        $attributes = request()->validate([
            'firstname' => 'required',
            'lastname'  => 'required',
            'email'     => 'required|email|' . Rule::unique('users')->ignore(user()->id),
            'password'  => 'nullable|min:4|confirmed',
            'cellphone' => 'nullable',
        ]);

        // update user
        user()->update([
            'firstname' => $attributes['firstname'],
            'lastname'  => $attributes['lastname'],
            'email'     => $attributes['email'],
            'cellphone' => $attributes['cellphone'],
        ]);

        // only update when a new password was entered
        $message = '';
        if ($attributes['password'] && strlen($attributes['password']) >= 2) {
            $message = " and <strong>Password</strong> ";
            user()->update([
                'password' => bcrypt($attributes['password']),
            ]);
        }

        alert()->success('Updated!',
            "Your personal information {$message} was successfully updated.");

        return redirect()->back();
    }
public function update()
    {
        $attributes = request()->validate([
            'firstname' => 'required',
            'lastname'  => 'required',
            'email'     => 'required|email|' . Rule::unique('users')->ignore(user()->id),
            'password'  => 'nullable|min:4|confirmed',
            'cellphone' => 'nullable',
        ]);

        // update user
        user()->update([
            'firstname' => $attributes['firstname'],
            'lastname'  => $attributes['lastname'],
            'email'     => $attributes['email'],
            'cellphone' => $attributes['cellphone'],
        ]);

        // only update when a new password was entered
        $message = '';
        if ($attributes['password'] && strlen($attributes['password']) >= 2) {
            $message = " and <strong>Password</strong> ";
            user()->update([
                'password' => bcrypt($attributes['password']),
            ]);
        }

        alert()->success('Updated!',
            "Your personal information {$message} was successfully updated.");

        return redirect()->back();
    }
public function update ( ) { $ attributes = request ( ) -> validate ( [ 'firstname' => 'required' , 'lastname' => 'required' , 'email' => 'required|email|' . Rule :: unique ( 'users' ) -> ignore ( user ( ) -> id ) , 'password' => 'nullable|min:4|confirmed' , 'cellphone' => 'nullable' , ] ) ; // update user user ( ) -> update ( [ 'firstname' => $ attributes [ 'firstname' ] , 'lastname' => $ attributes [ 'lastname' ] , 'email' => $ attributes [ 'email' ] , 'cellphone' => $ attributes [ 'cellphone' ] , ] ) ; // only update when a new password was entered $ message = '' ; if ( $ attributes [ 'password' ] && strlen ( $ attributes [ 'password' ] ) >= 2 ) { $ message = " and <strong>Password</strong> " ; user ( ) -> update ( [ 'password' => bcrypt ( $ attributes [ 'password' ] ) , ] ) ; } alert ( ) -> success ( 'Updated!' , "Your personal information {$message} was successfully updated." ) ; return redirect ( ) -> back ( ) ; }
Update the user's profile info
@return \Illuminate\Http\RedirectResponse
Update the user s profile info