public function findByUserNameOrCreate($userData)
 {
     $user = User::where('provider_id', '=', $userData->id)->orWhere('email', $userData->email)->first();
     if (!$user) {
         $user = new User();
         $user->provider_id = $userData->id;
         $user->name = $userData->name;
         $user->email = $userData->email;
         $user->avatar = $userData->avatar;
         $user->save();
     }
     $this->checkIfUserNeedsUpdating($userData, $user);
     return $user;
 }
 public function postRegister(Request $request)
 {
     $rules = ['name' => 'required', 'email' => 'required|email|unique:users,email', 'password' => 'required|min:5', 'signup_confirm' => 'required'];
     $request->old('name');
     $request->old('email');
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         $message = $validator->messages();
         return Redirect::route('register')->withInput()->withErrors($message);
     }
     $user = new User();
     $user->name = $request->get('name');
     $user->email = $request->get('email');
     $user->password = Hash::make($request->get('password'));
     $user->save();
     $currentUser = User::orderBy('id', 'Desc')->first();
     $userId = new UserProfile();
     $userId->user_id = $currentUser['id'];
     $userId->save();
     Session::flash('register-successful', 'User has been successfully registered');
     return Redirect::route('register');
 }