public function deleteUser($id)
 {
     UserAction::Where('user_id', '=', $id)->delete();
     UserLocation::Where('user_id', '=', $id)->delete();
     User::Where('id', '=', $id)->delete();
     return response()->json(["Response" => "success", "message" => "User Deleted"]);
 }
Beispiel #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(User $users, Request $request, UserGroup $user_groups, UserLocation $user_locations)
 {
     $user = array();
     $user = $request->all();
     if ($request->get('password') != null) {
         $user['password'] = Hash::make($request->get('password'));
     } else {
         unset($user['password']);
     }
     unset($user['_token']);
     unset($user['_method']);
     unset($user['photo']);
     unset($user['dob']);
     unset($user['group_id']);
     unset($user['retype_password']);
     $users->where('id', '=', $request->get('id'))->update($user);
     $locations = array();
     $locations['location_id'] = Session::get('location_id');
     $userId = $user['id'];
     $user_locations->where('user_id', $userId)->update($locations);
     $group = array();
     $group['group_id'] = $request->get('group_id');
     //$userId = $request->get('user_id');
     $user_groups->where('user_id', $userId)->update($group);
     return Redirect::route('users.index');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, $locationid)
 {
     //
     $allLocations = UserLocation::Where('location_id', '=', $locationid)->lists('user_id');
     UserAction::WhereIn('user_id', $allLocations)->delete();
     UserLocation::WhereIn('user_id', $allLocations)->delete();
     User::WhereIn('id', $allLocations)->delete();
     Location::Where('id', '=', $locationid)->delete();
     return response()->json(["Response" => "success", "message" => "Location Deleted"]);
 }