/** * Update the user's contact details * @param UpdateUserContactDetails $request * @return Redirect */ public function postUpdateContactDetails(UpdateUserContactDetails $request, Address $address) { \Auth::user()->profile()->update($request->only('phone')); $location = Location::firstOrCreate(['city_id' => City::where('name', $request->only('city'))->first()->id, 'region_id' => Region::where('name', $request->only('region'))->first()->id, 'country_id' => Country::where('name', $request->only('country'))->first()->id]); $address_data = $request->only('line1', 'line2', 'pincode'); $address_data['location_id'] = $location->id; $address->createOrUpdate($address_data); return redirect('update/profile/photo'); }
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'); }