Profile-update-code-rework
https://github.com/ladybirdweb/faveo-helpdesk/issues/257 solved
This commit is contained in:
@@ -191,7 +191,7 @@ class GroupController extends Controller
|
|||||||
if ($users) {
|
if ($users) {
|
||||||
$user = '<li>'.Lang::get('lang.there_are_agents_assigned_to_this_group_please_unassign_them_from_this_group_to_delete').'</li>';
|
$user = '<li>'.Lang::get('lang.there_are_agents_assigned_to_this_group_please_unassign_them_from_this_group_to_delete').'</li>';
|
||||||
|
|
||||||
return redirect('groups')->with('fails', Lang('lang.group_cannot_delete').$user);
|
return redirect('groups')->with('fails', Lang::get('lang.group_cannot_delete').$user);
|
||||||
}
|
}
|
||||||
$group_assign_department->where('group_id', $id)->delete();
|
$group_assign_department->where('group_id', $id)->delete();
|
||||||
$groups = $group->whereId($id)->first();
|
$groups = $group->whereId($id)->first();
|
||||||
|
@@ -668,60 +668,46 @@ class UserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function postProfileedit(ProfileRequest $request)
|
public function postProfileedit(ProfileRequest $request)
|
||||||
{
|
{
|
||||||
// geet authenticated user details
|
try {
|
||||||
$user = Auth::user();
|
// geet authenticated user details
|
||||||
$user->gender = $request->input('gender');
|
$user = Auth::user();
|
||||||
$user->save();
|
if ($request->get('country_code') == '' && ($request->get('phone_number') != '' || $request->get('mobile') != '')) {
|
||||||
// checking availability of agent profile ppicture
|
return redirect()->back()->with(['fails' => Lang::get('lang.country-code-required-error'), 'country_code_error' => 1])->withInput();
|
||||||
if ($user->profile_pic == 'avatar5.png' || $user->profile_pic == 'avatar2.png') {
|
} else {
|
||||||
if ($request->input('gender') == 1) {
|
$code = CountryCode::select('phonecode')->where('phonecode', '=', $request->get('country_code'))->get();
|
||||||
$name = 'avatar5.png';
|
if (!count($code)) {
|
||||||
$destinationPath = 'uploads/profilepic';
|
return redirect()->back()->with(['fails' => Lang::get('lang.incorrect-country-code-error'), 'country_code_error' => 1])->withInput();
|
||||||
$user->profile_pic = $name;
|
}
|
||||||
} elseif ($request->input('gender') == 0) {
|
$user->country_code = $request->country_code;
|
||||||
$name = 'avatar2.png';
|
|
||||||
$destinationPath = 'uploads/profilepic';
|
|
||||||
$user->profile_pic = $name;
|
|
||||||
}
|
}
|
||||||
}
|
$user->fill($request->except('profile_pic', 'mobile'));
|
||||||
// checking if the post system includes agent profile picture upload
|
$user->gender = $request->input('gender');
|
||||||
if (Input::file('profile_pic')) {
|
$user->save();
|
||||||
|
if (Input::file('profile_pic')) {
|
||||||
// fetching picture name
|
// fetching picture name
|
||||||
$name = Input::file('profile_pic')->getClientOriginalName();
|
$name = Input::file('profile_pic')->getClientOriginalName();
|
||||||
// fetching upload destination path
|
// fetching upload destination path
|
||||||
$destinationPath = 'uploads/profilepic';
|
$destinationPath = 'uploads/profilepic';
|
||||||
// adding a random value to profile picture filename
|
// adding a random value to profile picture filename
|
||||||
$fileName = rand(0000, 9999).'.'.$name;
|
$fileName = rand(0000, 9999).'.'.$name;
|
||||||
// moving the picture to a destination folder
|
// moving the picture to a destination folder
|
||||||
Input::file('profile_pic')->move($destinationPath, $fileName);
|
Input::file('profile_pic')->move($destinationPath, $fileName);
|
||||||
// saving filename to database
|
// saving filename to database
|
||||||
$user->profile_pic = $fileName;
|
$user->profile_pic = $fileName;
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
if ($request->get('country_code') == '' && ($request->get('phone_number') != '' || $request->get('mobile') != '')) {
|
|
||||||
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(['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', 'gender', 'mobile'))->save();
|
|
||||||
if ($request->get('mobile')) {
|
|
||||||
$user->mobile = $request->get('mobile');
|
|
||||||
} else {
|
|
||||||
$user->mobile = null;
|
|
||||||
}
|
|
||||||
$user->save();
|
|
||||||
|
|
||||||
return Redirect::route('profile')->with('success', Lang::get('lang.Profile-Updated-sucessfully'));
|
|
||||||
} catch (Exception $e) {
|
|
||||||
return Redirect::route('profile')->with('success', $e->getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
if ($request->get('mobile')) {
|
||||||
if ($user->fill($request->except('profile_pic'))->save()) {
|
$user->mobile = $request->get('mobile');
|
||||||
return Redirect::route('profile')->with('success', Lang::get('lang.Profile-Updated-sucessfully'));
|
} else {
|
||||||
|
$user->mobile = null;
|
||||||
|
}
|
||||||
|
if ($user->save()) {
|
||||||
|
return Redirect::route('profile')->with('success', Lang::get('lang.Profile-Updated-sucessfully'));
|
||||||
|
} else {
|
||||||
|
return Redirect::route('profile')->with('fails', Lang::get('lang.Profile-Updated-sucessfully'));
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return Redirect::route('profile')->with('fails', $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user