src/Http/Controllers/EntranceController.php
public function sendReset(Request $request)
    {
        $user = User::where('email', '=', $request->email)->first();
        if($user !== null)
        {
            $existingReset = Password_reset::where('email', $request->email)->first();
            if($existingReset !== null)
            {

                $existingReset->created_at = Carbon::now()->toDateTimeString();
                $existingReset->save();

                \Mail::send(config('entrance.mail.password_reset'), ['reset' => $existingReset->token], function ($m) use ($user) {
                    $m->to($user->email, $user->name)->subject('Your Password Reset!');
                });

                $request->session()->flash('message', 'Er is een e-mail met een link verzonden.');
                return redirect()->route('reset.password');

            }
            else
            {
                $passwordReset = new Password_reset();
                $passwordReset->email = $request->email;
                $passwordReset->token = $request->_token;
                $passwordReset->created_at = Carbon::now()->toDateTimeString();
                $passwordReset->save();

                \Mail::send(config('entrance.mail.password_reset'), ['reset' => $request->_token], function ($m) use ($user) {
                    $m->to($user->email, $user->name)->subject('Your Password Reset!');
                });

                $request->session()->flash('message', 'Er is een e-mail met een link verzonden.');
                return redirect()->route('reset.password');
            }
        }
        else
        {

            $request->session()->flash('message', 'Er bestaat geen gebruiker met het ingevoerde e-mail adres.');
            return redirect()->route('reset.password');
        }
    }
public function sendReset(Request $request)
    {
        $user = User::where('email', '=', $request->email)->first();
        if($user !== null)
        {
            $existingReset = Password_reset::where('email', $request->email)->first();
            if($existingReset !== null)
            {

                $existingReset->created_at = Carbon::now()->toDateTimeString();
                $existingReset->save();

                \Mail::send(config('entrance.mail.password_reset'), ['reset' => $existingReset->token], function ($m) use ($user) {
                    $m->to($user->email, $user->name)->subject('Your Password Reset!');
                });

                $request->session()->flash('message', 'Er is een e-mail met een link verzonden.');
                return redirect()->route('reset.password');

            }
            else
            {
                $passwordReset = new Password_reset();
                $passwordReset->email = $request->email;
                $passwordReset->token = $request->_token;
                $passwordReset->created_at = Carbon::now()->toDateTimeString();
                $passwordReset->save();

                \Mail::send(config('entrance.mail.password_reset'), ['reset' => $request->_token], function ($m) use ($user) {
                    $m->to($user->email, $user->name)->subject('Your Password Reset!');
                });

                $request->session()->flash('message', 'Er is een e-mail met een link verzonden.');
                return redirect()->route('reset.password');
            }
        }
        else
        {

            $request->session()->flash('message', 'Er bestaat geen gebruiker met het ingevoerde e-mail adres.');
            return redirect()->route('reset.password');
        }
    }
public function sendReset ( Request $ request ) { $ user = User :: where ( 'email' , '=' , $ request -> email ) -> first ( ) ; if ( $ user !== null ) { $ existingReset = Password_reset :: where ( 'email' , $ request -> email ) -> first ( ) ; if ( $ existingReset !== null ) { $ existingReset -> created_at = Carbon :: now ( ) -> toDateTimeString ( ) ; $ existingReset -> save ( ) ; \ Mail :: send ( config ( 'entrance.mail.password_reset' ) , [ 'reset' => $ existingReset -> token ] , function ( $ m ) use ( $ user ) { $ m -> to ( $ user -> email , $ user -> name ) -> subject ( 'Your Password Reset!' ) ; } ) ; $ request -> session ( ) -> flash ( 'message' , 'Er is een e-mail met een link verzonden.' ) ; return redirect ( ) -> route ( 'reset.password' ) ; } else { $ passwordReset = new Password_reset ( ) ; $ passwordReset -> email = $ request -> email ; $ passwordReset -> token = $ request -> _token ; $ passwordReset -> created_at = Carbon :: now ( ) -> toDateTimeString ( ) ; $ passwordReset -> save ( ) ; \ Mail :: send ( config ( 'entrance.mail.password_reset' ) , [ 'reset' => $ request -> _token ] , function ( $ m ) use ( $ user ) { $ m -> to ( $ user -> email , $ user -> name ) -> subject ( 'Your Password Reset!' ) ; } ) ; $ request -> session ( ) -> flash ( 'message' , 'Er is een e-mail met een link verzonden.' ) ; return redirect ( ) -> route ( 'reset.password' ) ; } } else { $ request -> session ( ) -> flash ( 'message' , 'Er bestaat geen gebruiker met het ingevoerde e-mail adres.' ) ; return redirect ( ) -> route ( 'reset.password' ) ; } }
Sends a password reset e-mail to the user.
@param Request $request
@return void
@author David Bikanov
Sends a password reset e - mail to the user .