public function users() { if (Auth::check()) { $users = User::all(); $softDeletedUsers = User::onlyTrashed()->get(); $winners = Winner::all(); return view('admin/users', compact('users', 'softDeletedUsers', 'winners')); } else { return view('errors/404'); } }
/** * Show a list of all the users. * * @return View */ public function getIndex() { // Grab all the users $users = User::All(); // Do we want to include the deleted users? if (Input::get('withTrashed')) { $users = User::withTrashed()->get(); } elseif (Input::get('onlyTrashed')) { $users = User::onlyTrashed()->get(); } // Show the page return View::make('admin.users.index', compact('users')); }
public function restore($id) { $id = intval($id); $userInstance = User::onlyTrashed()->findOrFail($id); $userInstance->comments->each(function ($comment) { Comment::withTrashed()->find($comment->id)->restore(); }); if ($userInstance->restore()) { return redirect()->back()->with('success', 'restore success'); } else { return redirect()->back()->withError('this user haven\'t been deleted yet.'); } }
/** * @param $per_page * @return \Illuminate\Pagination\Paginator */ public function getDeletedUsersPaginated($per_page) { return User::onlyTrashed()->paginate($per_page); }
public function restaurar(Request $request) { $datos = User::onlyTrashed($request->id)->restore(); $datos = User::onlyTrashed($request->buscar)->OrderBy('id', 'ASC')->paginate(5); Flash::success("Se ha Resturado de forma exitosa!"); return view('usuarios.index')->with('datos', $datos)->with('buscar', $request->buscar); }
public function restore($id) { $user = User::onlyTrashed()->where('id', $id)->restore(); $users = User::withTrashed()->get(); $restore = "RESTORED"; return view('listUsers')->with(compact('restore'))->with(compact('users')); }
public function testRestoreFromTrash() { $credentials = ['email' => '*****@*****.**', 'password' => '123456']; $token = JWTAuth::attempt($credentials); // test find not found $res = $this->call('POST', '/users/5/restore', [], [], [], ['HTTP_Authorization' => "Bearer {$token}"]); $this->assertEquals('404', $res->getStatusCode()); // test restore user $user = factory(App\User::class)->create(); $res = $this->call('POST', '/users/' . $user->id . '/trash', [], [], [], ['HTTP_Authorization' => "Bearer {$token}"]); $res = $this->call('POST', '/users/' . $user->id . '/restore', [], [], [], ['HTTP_Authorization' => "Bearer {$token}"]); $this->assertEquals('204', $res->getStatusCode()); $exists = App\User::find($user->id); $this->assertEquals($user->name, $exists->name); $existsTrash = App\User::onlyTrashed()->count(); $this->assertEquals(0, $existsTrash); }
/** * Show a list of all the deleted users. * * @return View */ public function getDeletedUsers() { // Grab deleted users $users = User::onlyTrashed()->get(); // Show the page return View('admin/deleted_users', compact('users')); }
/** * restore user * @param int $id * @return Response */ public function restoreFromTrash($id) { $user = AppUser::onlyTrashed()->where('id', $id); if (!$user->count()) { return response()->json(null, 404); } if (!$user->restore()) { return response()->json(null, 500); // @codeCoverageIgnore } return response()->json(null, 204); }
public function pardonUser($id) { User::onlyTrashed()->where('id', '=', $id)->restore(); return true; }
protected function portalRestoreEmployee($id) { if ( \Auth::user() ) { $userTypeID = \Auth::user()->userTypeId; if ( $userTypeID == 1 ) { $empId = $id; $employee = Employee::onlyTrashed()->where('id','=',$empId)->first(); $empUserId = $employee->userId; $user = User::onlyTrashed()->where('id','=',$empUserId)->first(); $timesheet = Timesheet::onlyTrashed()->where('empId','=',$empId)->first(); $employee->restore(); $user->restore(); $timesheet->restore(); return Redirect::to('/portal-employees'); } else if ( $userTypeID == 2 ) { return Redirect::to('/portal-settings'); } else { return Redirect::to('/account'); } } else { return Redirect::to('/'); } }
/** * @param bool $trashed * @return \Illuminate\View\View */ public function index($trashed = false) { $data = ['users' => !$trashed ? $this->user->orderBy('lastname', 'ASC')->paginate($this->config->items_per_page) : $this->user->onlyTrashed()->orderBy('name', 'ASC')->paginate($this->config->items_per_page), 'trashed' => $trashed]; return view('blogify::admin.users.index', $data); }