I have used laravel 5.2 default user registration and login Form. My requirement is creating two type of users. it is not kind of user and admin. But its two type of user in the website user1 and user2 having different fields in the registration form.So for this i have copied register.blad.php and create a function in authcontroller. For distinguishing two form values in database i have used a field named user_type. user_type is hidden field in the both registration form. here is my auth controller
protected function create(array $data) { return User::create([ 'name' => $data['name'], 'email' => $data['email'], 'user_type'=> $data['user_type'], 'password' => bcrypt($data['password']), ]); } /* custom function for user type */ public function getRecruiter(){ return view('auth.recruiter'); } public function postRecruiter(Request $request){ $this->validate($request, [ 'name' => 'required|max:255', 'email' => 'required|email|unique:users', 'password'=> 'required|min:6', 'company'=>'required', 'location'=>'required', 'url'=>'required' ]); $user = User::create([ 'name' => $request->name, 'email' => $request->email, 'user_type'=> $request->user_type, // user_type for second user type. 'password' => bcrypt($request->password), ]); return view('home'); }
every thing is working fine but user_type, remember_token is not saving in database.
Last is. I do not know how to login user after register. like default functionality. if i use Auth::login($user) then it is giving error.
App\Http\Controllers\Auth\auth not found.
Please help me solve this as I do not want to create any other table . As many thready were like having two tables but i want to solve it with one table with different user type.
$request
variable inpostRecruiter
haveuser_type
. – Abbasi