/**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $verification_token = str_random(50);
     $user = User::create(['username' => $data['username'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'verification_token' => $verification_token]);
     Profile::create(['user_id' => $user->id, 'firstname' => $data['firstname'], 'lastname' => $data['lastname'], 'gender' => $data['gender']]);
     Event::fire(new UserRegistered($user));
     return $user;
 }
 public function postUpdateProfile(UpdateUserProfileDetails $request)
 {
     $user = \Auth::user()->profile()->update($request->only('phone'));
     $city = City::where('name', $request->only('city'))->first();
     $region = Region::where('name', $request->only('region'))->first();
     $country = Country::where('name', $request->only('country'))->first();
     $location = Location::firstOrCreate(['city_id' => $city->id, 'region_id' => $region->id, 'country_id' => $country->id]);
     $address_data = $request->only('line1', 'line2', 'pincode');
     $profile = Profile::where('user_id', $user)->first();
     $address_data['location_id'] = $location->id;
     $address_data['addressable_id'] = $profile->user_id;
     $address = Profile::find($profile->id)->address()->update($address_data);
     return redirect('update/profile/photo');
 }