We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 3 |
| Paths | 3 |
| Total Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function recover(Request $request) |
||
| 19 | { |
||
| 20 | $user = User::where('email', $request->email)->first(); |
||
| 21 | if (!$user) { |
||
| 22 | $error_message = "Your email address was not found."; |
||
| 23 | return response()->json([ 'success' => false, 'error' => [ 'email' => $error_message ] ], 401); |
||
|
|
|||
| 24 | } |
||
| 25 | |||
| 26 | try { |
||
| 27 | Password::sendResetLink( |
||
| 28 | $request->only('email'), function (Message $message) { |
||
| 29 | $message->subject('Your Password Reset Link'); |
||
| 30 | } |
||
| 31 | ); |
||
| 32 | } catch (Exception $e) { |
||
| 33 | // Return with error |
||
| 34 | $error_message = $e->getMessage(); |
||
| 35 | return response()->json([ 'success' => false, 'error' => $error_message ], 401); |
||
| 36 | } |
||
| 37 | |||
| 38 | return response()->json( |
||
| 39 | [ |
||
| 40 | 'success' => true, |
||
| 41 | 'data' => [ 'message' => 'A reset email has been sent! Please check your email.' ] |
||
| 42 | ] |
||
| 43 | ); |
||
| 44 | } |
||
| 45 | } |
||
| 46 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: