1 | <?php namespace App\Http\Controllers\Users; |
||
9 | class PasswordController extends Controller |
||
10 | { |
||
11 | /** |
||
12 | * Create a new password controller instance. |
||
13 | */ |
||
14 | 12 | public function __construct() |
|
18 | |||
19 | /** |
||
20 | * Display the form to request a password reset link. |
||
21 | * |
||
22 | * @param \Illuminate\Http\Request $request |
||
23 | * |
||
24 | * @return \Illuminate\Http\JsonResponse|\Illuminate\View\View|\Illuminate\Contracts\View\Factory |
||
25 | */ |
||
26 | 5 | public function getEmail(Request $request) |
|
34 | |||
35 | /** |
||
36 | * Send a password reset link to the given email's owner, via email. |
||
37 | * |
||
38 | * @param \Illuminate\Http\Request $request |
||
39 | * @param \App\Contracts\Registrar $registrar |
||
40 | * |
||
41 | * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse |
||
42 | */ |
||
43 | 2 | public function postEmail(Request $request, Registrar $registrar) |
|
44 | { |
||
45 | 2 | $registrar->sendResetPasswordLinkViaEmail(); |
|
46 | |||
47 | 1 | if ($request->ajax() || $request->wantsJson()) { |
|
48 | return response()->json(['message' => trans('passwords.sent')]); |
||
49 | } |
||
50 | |||
51 | 1 | return redirect()->back()->with('message', trans('passwords.sent')); |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * Display the password reset view for the given token. |
||
56 | * |
||
57 | * @param \Illuminate\Http\Request $request |
||
58 | * @param string $token |
||
59 | * |
||
60 | * @return \Illuminate\Http\JsonResponse|\Illuminate\View\View|\Illuminate\Contracts\View\Factory |
||
61 | */ |
||
62 | 7 | public function getReset(Request $request, $token = null) |
|
78 | |||
79 | /** |
||
80 | * Reset the password through password-reset-token and email provided. |
||
81 | * |
||
82 | * @param \Illuminate\Http\Request $request |
||
83 | * @param \App\Contracts\Registrar $registrar |
||
84 | * |
||
85 | * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse |
||
86 | */ |
||
87 | 6 | public function postReset(Request $request, Registrar $registrar) |
|
88 | { |
||
89 | 6 | $registrar->resetPassword(); |
|
90 | |||
91 | 1 | if ($request->ajax() || $request->wantsJson()) { |
|
92 | return response()->json(['message' => trans('passwords.reset')]); |
||
93 | } |
||
94 | |||
95 | 1 | return redirect($this->redirectPath())->with('message', trans('passwords.reset')); |
|
96 | } |
||
97 | |||
98 | /** |
||
99 | * Get the post-register/-login redirect path. |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | 1 | private function redirectPath() |
|
111 | } |
||
112 |
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: