ForgotPasswordSubmitEmailController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 15 2
1
<?php
2
3
namespace App\Http\Controllers\Auth;
4
5
use App\Events\FailedResetEmailAttempt;
6
use App\Events\SuccessfulResetEmailAttempt;
7
use Illuminate\Support\Facades\Password;
8
9
use App\Http\Controllers\Controller;
10
use App\Http\Requests\Auth\ForgotPasswordEmailRequest;
11
12
class ForgotPasswordSubmitEmailController extends Controller
13
{
14
    /**
15
     *  Send the user an email with a link to reset their password
16
     */
17
    public function __invoke(ForgotPasswordEmailRequest $request)
18
    {
19
        $status = Password::sendResetLink($request->only('email'));
20
21
        if($status === Password::RESET_LINK_SENT)
22
        {
23
            event(new SuccessfulResetEmailAttempt($request->email));
24
            return back()->with([
25
                'message' => __($status),
26
                'type'    => 'success'
27
            ]);
28
        }
29
30
        event(new FailedResetEmailAttempt($request->email));
31
        return back()->withErrors(['email' => __($status)]);
32
    }
33
}
34