public function changeEmail(Request $request)
    {
        $this->validate(
            $request,
            [
                'email' => 'required|email',
            ]
        );

        if ($request->input('email') == Auth::user()->email) {
            return redirect()->back()->withErrors([
                'email' => trans('mustard::account.email_same'),
            ]);
        }

        if (User::findByEmail($request->input('email'))) {
            return redirect()->back()->withErrors([
                'email' => trans('mustard::account.email_exists'),
            ]);
        }

        // Notify the old email
        Auth::user()->sendEmail(
            trans('mustard::account.email_changed'),
            'mustard::emails.account.email-changed',
            ['new_email' => $request->input('email')]
        );

        Auth::user()->email = $request->input('email');

        if (method_exists('unverify', Auth::user())) {
            Auth::user()->unverify();
        }

        Auth::user()->save();

        return redirect()->back()->withStatus(trans('mustard::account.email_changed'));
    }
public function changeEmail(Request $request)
    {
        $this->validate(
            $request,
            [
                'email' => 'required|email',
            ]
        );

        if ($request->input('email') == Auth::user()->email) {
            return redirect()->back()->withErrors([
                'email' => trans('mustard::account.email_same'),
            ]);
        }

        if (User::findByEmail($request->input('email'))) {
            return redirect()->back()->withErrors([
                'email' => trans('mustard::account.email_exists'),
            ]);
        }

        // Notify the old email
        Auth::user()->sendEmail(
            trans('mustard::account.email_changed'),
            'mustard::emails.account.email-changed',
            ['new_email' => $request->input('email')]
        );

        Auth::user()->email = $request->input('email');

        if (method_exists('unverify', Auth::user())) {
            Auth::user()->unverify();
        }

        Auth::user()->save();

        return redirect()->back()->withStatus(trans('mustard::account.email_changed'));
    }
public function changeEmail ( Request $ request ) { $ this -> validate ( $ request , [ 'email' => 'required|email' , ] ) ; if ( $ request -> input ( 'email' ) == Auth :: user ( ) -> email ) { return redirect ( ) -> back ( ) -> withErrors ( [ 'email' => trans ( 'mustard::account.email_same' ) , ] ) ; } if ( User :: findByEmail ( $ request -> input ( 'email' ) ) ) { return redirect ( ) -> back ( ) -> withErrors ( [ 'email' => trans ( 'mustard::account.email_exists' ) , ] ) ; } // Notify the old email Auth :: user ( ) -> sendEmail ( trans ( 'mustard::account.email_changed' ) , 'mustard::emails.account.email-changed' , [ 'new_email' => $ request -> input ( 'email' ) ] ) ; Auth :: user ( ) -> email = $ request -> input ( 'email' ) ; if ( method_exists ( 'unverify' , Auth :: user ( ) ) ) { Auth :: user ( ) -> unverify ( ) ; } Auth :: user ( ) -> save ( ) ; return redirect ( ) -> back ( ) -> withStatus ( trans ( 'mustard::account.email_changed' ) ) ; }
Change account email address.

@return \Illuminate\Http\RedirectResponse
Change account email address .