Redirect To Create Method Of RegisterController In Laravel
I Wanted to redirect to create method of registerController in laravel after a particular action.
So that the user can login after the registration is complete
Answer
Assuming you are using the default RegisterController
provided by Laravel.
create
is a protected method, so you cannot use it as an action in a Route; you may only use public methods there.
The public methods that are meant as route actions in the default implementation are:
showRegistrationForm
register
(this one callscreate
internally)
So either redirect him to the Route that has showRegistrationForm
as action - the user may then fill out the form, submit it, and is registered.
Or programmatically create the user in your particular action using User::create()
. You can even use the returned/created User
object to programmatically login the user in the current session using Auth::login()
:
// Creates the record in the database. $newUser returned by the create method is the created User object.
$newUser = \App\User::create([
'email' => '[email protected]',
'password' => bcrypt('thepasswordforthenewuser'),
]);
// Pass to the SessionGuard to log him in.
\Auth::login($newUser);
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms