added logic for updating user profile plus other bug fixes
This commit is contained in:
@@ -53,6 +53,12 @@ class SystemUsersController extends Controller
|
||||
|
||||
return view('systemusers.index', $data);
|
||||
}
|
||||
public function profile_json(){
|
||||
$staff_member_id = session('current_user.id');
|
||||
$staff_member = Models\SystemUser::findOrFail($staff_member_id);
|
||||
|
||||
return response()->json(['code' => 1, 'staff_member' => $staff_member]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
@@ -156,6 +162,25 @@ class SystemUsersController extends Controller
|
||||
Session::flash('success_message', 'Account successfully Updated');
|
||||
return redirect(url('systemusers'));
|
||||
}
|
||||
public function profileupdate(Request $request){
|
||||
$account_arr = Models\SystemUser::find($request->user_id);
|
||||
$account_arr->name = $request->name;
|
||||
$account_arr->email = $request->email;
|
||||
$account_arr->phone = $request->phone;
|
||||
$msg_text = 'Account successfully Updated';
|
||||
if ($request->password == true) {
|
||||
$account_arr->password = md5($request->password);
|
||||
$msg_text = "Account details and password successfully updated";
|
||||
}
|
||||
$result = $account_arr->save();
|
||||
if ($result == true) {
|
||||
$data = ['code' => 1, 'msg' => $msg_text];
|
||||
}
|
||||
else{
|
||||
$data = ['code' => 1, 'msg' => 'Account could not be updated at this time. Try again!'];
|
||||
}
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
|
||||
Reference in New Issue
Block a user