Profile edit bug fix patch
This commit is contained in:
		| @@ -240,7 +240,8 @@ class AgentController extends Controller | ||||
|             if ($request->input('country_code') != '' or $request->input('country_code') != null) { | ||||
|                 $user->country_code = $request->input('country_code'); | ||||
|             } | ||||
|             $user->fill($request->except('daylight_save', 'limit_access', 'directory_listing', 'vocation_mode', 'assign_team'))->save(); | ||||
|             $user->mobile = ($request->input('mobile') == '') ? null : $request->input('mobile'); | ||||
|             $user->fill($request->except('daylight_save', 'limit_access', 'directory_listing', 'vocation_mode', 'assign_team', 'mobile')); | ||||
|             $user->assign_group = $request->group; | ||||
|             $user->primary_dpt = $request->primary_department; | ||||
|             $user->agent_tzone = $request->agent_time_zone; | ||||
|   | ||||
| @@ -610,8 +610,9 @@ class UserController extends Controller | ||||
|                     $users->country_code = $request->country_code; | ||||
|                 } | ||||
|             } | ||||
|             // dd($request->input()); | ||||
|             $users->fill($request->input())->save(); | ||||
|             $users->mobile = ($request->input('mobile') == '') ? null : $request->input('mobile'); | ||||
|             $users->fill($request->except('mobile')); | ||||
|             $users->save(); | ||||
|             $orgid = $request->input('org_id'); | ||||
|             $this->storeUserOrgRelation($users->id, $orgid); | ||||
|             /* redirect to Index page with Success Message */ | ||||
|   | ||||
| @@ -80,58 +80,43 @@ class GuestController extends Controller | ||||
|      */ | ||||
|     public function postProfile(ProfileRequest $request) | ||||
|     { | ||||
|         $user = User::where('id', '=', Auth::user()->id)->first(); | ||||
|         $user->gender = $request->get('gender'); | ||||
|         $user->save(); | ||||
|         if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') { | ||||
|             if ($request->input('gender') == 1) { | ||||
|                 $name = 'avatar5.png'; | ||||
|                 $destinationPath = 'uploads/profilepic'; | ||||
|                 $user->profile_pic = $name; | ||||
|             } elseif ($request->input('gender') == 0) { | ||||
|                 $name = 'avatar2.png'; | ||||
|                 $destinationPath = 'uploads/profilepic'; | ||||
|                 $user->profile_pic = $name; | ||||
|             } | ||||
|         } | ||||
|         if (Input::file('profile_pic')) { | ||||
|             //$extension = Input::file('profile_pic')->getClientOriginalExtension(); | ||||
|             $name = Input::file('profile_pic')->getClientOriginalName(); | ||||
|             $destinationPath = 'uploads/profilepic'; | ||||
|             $fileName = rand(0000, 9999).'.'.$name; | ||||
|             //echo $fileName; | ||||
|             Input::file('profile_pic')->move($destinationPath, $fileName); | ||||
|             $user->profile_pic = $fileName; | ||||
|         } else { | ||||
|         try { | ||||
|             // geet authenticated user details | ||||
|             $user = Auth::user(); | ||||
|             if ($request->get('country_code') == '' && ($request->get('phone_number') != '' || $request->get('mobile') != '')) { | ||||
|                 return redirect()->back()->with(['fails1' => Lang::get('lang.country-code-required-error'), | ||||
|                             'country_code'                => 1, ])->withInput(); | ||||
|                 return redirect()->back()->with(['fails' => Lang::get('lang.country-code-required-error'), 'country_code_error' => 1])->withInput(); | ||||
|             } else { | ||||
|                 $code = CountryCode::select('phonecode')->where('phonecode', '=', $request->get('country_code'))->get(); | ||||
|                 if (!count($code)) { | ||||
|                     return redirect()->back()->with(['fails1' => Lang::get('lang.incorrect-country-code-error'), | ||||
|                                 'country_code'                => 1, ])->withInput(); | ||||
|                 } else { | ||||
|                     $user->country_code = $request->input('country_code'); | ||||
|                 } | ||||
|                     return redirect()->back()->with(['fails' => Lang::get('lang.incorrect-country-code-error'), 'country_code_error' => 1])->withInput(); | ||||
|                  } | ||||
|                 $user->country_code = $request->country_code; | ||||
|             } | ||||
|             $user->fill($request->except('profile_pic', 'mobile')); | ||||
|             $user->gender = $request->input('gender'); | ||||
|             $user->save(); | ||||
|             if (Input::file('profile_pic')) { | ||||
|             // fetching picture name | ||||
|                 $name = Input::file('profile_pic')->getClientOriginalName(); | ||||
|             // fetching upload destination path | ||||
|                 $destinationPath = 'uploads/profilepic'; | ||||
|             // adding a random value to profile picture filename | ||||
|                 $fileName = rand(0000, 9999).'.'.$name; | ||||
|             // moving the picture to a destination folder | ||||
|                 Input::file('profile_pic')->move($destinationPath, $fileName); | ||||
|             // saving filename to database | ||||
|                 $user->profile_pic = $fileName; | ||||
|             } | ||||
|             if ($request->get('mobile')) { | ||||
|                 $mobile = $request->get('mobile'); | ||||
|                 $user->mobile = $request->get('mobile'); | ||||
|             } else { | ||||
|                 $mobile = null; | ||||
|                 $user->mobile = null; | ||||
|             } | ||||
|             $check = $this->checkMobile($mobile); | ||||
|             if ($check == true) { | ||||
|                 return redirect()->back()->with(['fails1' => Lang::get('lang.mobile-has-been-taken'), 'country_code' => 1])->withInput(); | ||||
|             if ($user->save()) { | ||||
|             } else { | ||||
|             } | ||||
|             $user->fill($request->except('profile_pic', 'gender', 'mobile')); | ||||
|             $user->mobile = $mobile; | ||||
|             $user->save(); | ||||
|  | ||||
|             return redirect()->back()->with('success1', Lang::get('lang.profile_updated_sucessfully')); | ||||
|         } | ||||
|         if ($user->fill($request->except('profile_pic'))->save()) { | ||||
|             return redirect()->back()->with('success1', Lang::get('lang.profile_updated_sucessfully')); | ||||
|         } catch (Exception $e) { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Manish Verma
					Manish Verma