I'm using Laravel 5.2 Auth feature and registration works fine.
Now I need to write a string in a special column in users table during registration. It's not a value from an HTML form input. It's a static text describing a user role (contributor). All users registering should receive a "contributor" value in user_role column.
I tried to achieve this by adding this line to AuthController.php:
'user_role' => 'contributor',
The whole function adding values to database looks like this:
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create([
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'user_role' => 'contributor',
]);
}
When I try to register a new account, everything except 'user_role' => 'contributor',
gets added.
What's the proper way to write "contributor" value for every new user into the user_role column?
Is it not working because that function only has the $data array set?