I'm trying to create two different registration pages for laravel - one will be for "students" and another for "mentors".
There are two ways in my head I could go about routing this:
Is to add in the localhost/register?user_type="mentor" and localhost/register?user_type="student". Then depending on the user_type parameter add a hidden input which will submit to laravel the user_type on registration.
To add a completely second registration page localhost/register_mentor or localhost/register_student
So, I used the makeauth scaffold. But here i'm confused.
In the "RegistrationController" I have
protected function create(array $data)
So I know I can edit this and add a user_type column in the database.
But I have no idea where this "create" is being called? So I don't know how to put in a a new registration page that will call this with the user_type.
Hope I make sense, any help would be greatly appreciated!
The create method is being called within the register()
method found in vendor/laravel/framework/src/Illuminate/Foundation/Auth/RegistersUsers.php
.
You can override the register()
method found by placing it in your RegisterController.
You also have access to the $request
instance in the register()
method so you can check for the url parameters.
In your RegisterController.php
add the register method:
public function register(Request $request)
{
$this->validator($request->all())->validate();
//Determine User type
if($request->user_type === 'mentor'){
event(new Registered($user = $this->create($request->all())));
}
$this->guard()->login($user);
return $this->registered($request, $user)
?: redirect($this->redirectPath());
}