本文整理汇总了PHP中app\User::onlyTrashed方法的典型用法代码示例。如果您正苦于以下问题:PHP User::onlyTrashed方法的具体用法?PHP User::onlyTrashed怎么用?PHP User::onlyTrashed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\User
的用法示例。
在下文中一共展示了User::onlyTrashed方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: users
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');
}
}
示例2: getIndex
/**
* 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'));
}
示例3: restore
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.');
}
}
示例4: getDeletedUsersPaginated
/**
* @param $per_page
* @return \Illuminate\Pagination\Paginator
*/
public function getDeletedUsersPaginated($per_page)
{
return User::onlyTrashed()->paginate($per_page);
}
示例5: restaurar
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);
}
示例6: restore
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'));
}
示例7: testRestoreFromTrash
public function testRestoreFromTrash()
{
$credentials = ['email' => 'admin@example.com', '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);
}
示例8: getDeletedUsers
/**
* 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'));
}
示例9: restoreFromTrash
/**
* 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);
}
示例10: pardonUser
public function pardonUser($id)
{
User::onlyTrashed()->where('id', '=', $id)->restore();
return true;
}
示例11: portalRestoreEmployee
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('/');
}
}
示例12: index
/**
* @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);
}