What would be the best approach for me to create two registration pages in Laravel 5.2? One should assign the user's role to 'buyer' and the other one to 'seller'. Thanks in advance!
Just create two views and pass some variable in registration form, like:
{!! Form::hidden('role', 'user') !!}
And then change create()
method in RegisterController
(if you're using 5.3) or AuthController
(for 5.2) to something like this:
protected function create(array $data)
{
return User::create([
'role' => $data['role'], // This will set role from hidden form element
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
Don't forget to add role
to $fillable
array in User
model.