You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The changes to the register and registered methods of the Illuminate\Foundation\Auth\RegistersUsers trait make it impossible to override these methods directly as described in the docs and upgrade guide.
From the upgrade guide for 6.0:
If you are overriding the register or registered methods of Laravel's built-in RegisterController, you should ensure that you are calling parent::register and parent::registered from within your respective methods. The dispatching of the Illuminate\Auth\Events\Registered event and the logging in of the newly registered user has been moved to the registered method, so if you are overriding this method and not calling the parent method, the user registration process will fail.
As far as I understand, in PHP you can't call a method provided directly by a trait using the parent keyword. Because the built-in RegisterController uses a trait rather than extending a parent class, defining a registered method in it will override the trait's registered method entirely. Calling parent::registered exactly as described in the upgrade guide throws a BadMethodCallException with the message Method App\Http\Controllers\Auth\RegisterController::registered does not exist.
I think the registered method is really useful, to be able to hook into registration and call stuff in my own controllers. I'd suggest we just move event(new Registered($user)) and $this->guard()->login($user) back into the register method, unless there's a reason not to keep them there. I'll start a PR.
Description:
The changes to the
register
andregistered
methods of theIlluminate\Foundation\Auth\RegistersUsers
trait make it impossible to override these methods directly as described in the docs and upgrade guide.From the upgrade guide for 6.0:
As far as I understand, in PHP you can't call a method provided directly by a trait using the
parent
keyword. Because the built-inRegisterController
uses a trait rather than extending a parent class, defining aregistered
method in it will override the trait'sregistered
method entirely. Callingparent::registered
exactly as described in the upgrade guide throws aBadMethodCallException
with the messageMethod App\Http\Controllers\Auth\RegisterController::registered does not exist
.See https://stackoverflow.com/a/11939306/6484459, http://docs.php.net/manual/da/keyword.parent.php, and https://andy-carter.com/blog/overriding-extending-a-php-trait-method.
Steps To Reproduce:
ui
package, set up the auth views, migrate the database.App\Http\Controllers\Auth\RegisterController
:BadMethodCallException: Method App\Http\Controllers\Auth\RegisterController::registered does not exist.
The text was updated successfully, but these errors were encountered: