public function createUserRequest(Request $request)
 {
     $skills = Skills::lists('name', 'name');
     $educationList = Education::orderBy('level')->orderBy('name')->where('name', '!=', '0')->get();
     $farearoleList = Functional_area_role_mapping::orderBy('id')->get();
     $indUser = new Induser();
     $indUser->fname = $request['fname'];
     $indUser->lname = $request['lname'];
     $indUser->gender = $request['gender'];
     $indUser->city = $request['city'];
     $indUser->about_individual = $request['about_individual'];
     $indUser->education = $request['education'];
     $indUser->experience = $request['experience'];
     $indUser->working_status = $request['working_status'];
     $indUser->working_at = $request['working_at'];
     $indUser->industry = $request['industry'];
     if ($request['role'] != null) {
         $farea_role = $request['role'];
         $temp = explode('-', $farea_role);
         $indUser->functional_area = $temp[0];
         $indUser->role = $temp[1];
     }
     if ($request['linked_skill_id'] != null) {
         $indUser->linked_skill = implode(', ', $request['linked_skill_id']);
     }
     if ($request['prefered_location'] != null) {
         $indUser->prefered_location = implode(', ', $request['prefered_location']);
     }
     $indUser->email = $request['email'];
     $indUser->mobile = $request['mobile'];
     $indUser->prefered_jobtype = $request['prefered_jobtype'];
     $indUser->save();
     $user = new User();
     $user->name = $request['fname'] . ' ' . $request['lname'];
     $user->email = $request['email'];
     $user->mobile = $request['mobile'];
     $user->password = md5(rand(111111, 999999));
     $user->identifier = 1;
     if ($request['email'] != null) {
         $vcode = 'A' . rand(1111, 9999);
         $user->email_vcode = $vcode;
     }
     if ($request['mobile'] != null) {
         $otp = rand(1111, 9999);
         $user->mobile_otp = $otp;
     }
     $resetCode = md5(rand(11111, 99999));
     $user->reset_code = $resetCode;
     $indUser->user()->save($user);
     $email = $request['email'];
     if ($request['email'] != null) {
         $email = $request['email'];
         $fname = $request['fname'];
         Mail::send('emails.auth.resetpassword', array('fname' => $fname, 'token' => $resetCode), function ($message) use($email, $fname) {
             $message->to($email, $fname)->subject('Jobtip - Profile Created!')->from('*****@*****.**', 'JobTip');
         });
     }
     return view('pages.create_users', compact('skills', 'educationList', 'farearoleList'))->withErrors(['errors' => 'Profile Created Successfully.']);
 }
Exemple #2
0
 public function handleLinkedinCallback()
 {
     $li_user = Socialize::with('linkedin')->user();
     $jtIndUser = Induser::where('email', '=', $li_user->getEmail())->first();
     $jtCorpUser = Corpuser::where('firm_email_id', '=', $li_user->getEmail())->first();
     $authUser = User::where('email', '=', $li_user->getEmail())->first();
     if (!empty($jtIndUser) && $li_user->token != null) {
         // user exist
         Auth::login($authUser);
         return Redirect::to('/home')->with('message', 'Logged in with Linkedin');
     } else {
         if (!empty($jtIndUser) && $li_user->token == null) {
             // user exist but social login failed
             return Redirect::to('/login')->with('message', 'Login failed using Linkedin');
         } else {
             if (!empty($jtCorpUser)) {
                 // corp user exist but social login not allowed
                 return Redirect::to('/login')->with('message', 'Social Login not allwoed for Corporate users');
             } else {
                 // user doesn't exist
                 DB::beginTransaction();
                 try {
                     $indUser = new Induser();
                     $indUser->fname = $li_user->user['firstName'];
                     $indUser->lname = $li_user->user['lastName'];
                     // $indUser->gender = $li_user->user['gender'];
                     $indUser->email = $li_user->getEmail();
                     $indUser->social_id = $li_user->getId();
                     $indUser->access_token = $li_user->token;
                     $indUser->avatar = $li_user->avatar;
                     $indUser->reg_via = 'linkedin';
                     $indUser->email_verify = '1';
                     $indUser->save();
                     $user = new User();
                     $user->name = $li_user->user['firstName'] . ' ' . $li_user->user['lastName'];
                     $user->email = $li_user->getEmail();
                     $user->email_verify = '1';
                     $user->identifier = 1;
                     $indUser->user()->save($user);
                 } catch (\Exception $e) {
                     DB::rollback();
                     throw $e;
                 }
                 DB::commit();
                 Auth::login($user);
                 return Redirect::to('/home')->with('message', 'Logged in with Linkedin');
             }
         }
     }
     // print_r($li_user);die;
 }