1 | <?php |
||
13 | class AuthController extends BaseController |
||
14 | { |
||
15 | /** |
||
16 | * Display the login form. |
||
17 | */ |
||
18 | public function login() |
||
22 | |||
23 | /** |
||
24 | * Log the user in |
||
25 | * |
||
26 | * @param Login $request |
||
27 | * |
||
28 | * @return mixed |
||
29 | */ |
||
30 | public function handleLogin(Login $request) |
||
31 | { |
||
32 | // Set the auth data |
||
33 | $userData = [ |
||
34 | 'username' => $request->get('username'), |
||
35 | 'password' => $request->get('password'), |
||
36 | ]; |
||
37 | |||
38 | // Log in successful |
||
39 | if (auth()->attempt($userData, $request->get('remember', false))) { |
||
40 | event(new UserLoggedIn(auth()->user())); |
||
|
|||
41 | |||
42 | return redirect() |
||
43 | ->intended(route('home')) |
||
44 | ->with('message', 'You have been logged in.'); |
||
45 | } |
||
46 | |||
47 | // Login failed |
||
48 | return redirect(route('auth.login')) |
||
49 | ->with('errors', ['Your username or password was incorrect.']); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Display the registration form. |
||
54 | */ |
||
55 | public function register() |
||
59 | |||
60 | /** |
||
61 | * Register a user |
||
62 | * |
||
63 | * @param Registration $request |
||
64 | * |
||
65 | * @return mixed |
||
66 | */ |
||
67 | public function handleRegister(Registration $request) |
||
68 | { |
||
69 | DB::beginTransaction(); |
||
70 | |||
71 | try { |
||
72 | $user = User::create($request->all()); |
||
73 | $user->assignRole(config('users.default')); |
||
74 | |||
75 | auth()->login($user); |
||
76 | |||
77 | event(new UserRegistered(auth()->user())); |
||
78 | } catch (\Exception $exception) { |
||
79 | DB::rollBack(); |
||
80 | |||
81 | return redirect(route('auth.register')) |
||
82 | ->with('errors', $exception->getMessage()); |
||
83 | } |
||
84 | |||
85 | DB::commit(); |
||
86 | |||
87 | return redirect(route('home')) |
||
88 | ->with('message', 'Your account has been created.'); |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * Log the user out. |
||
93 | * |
||
94 | * @return mixed |
||
95 | */ |
||
96 | public function logout() |
||
103 | } |
||
104 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: