本文整理汇总了PHP中app\User::withTrashed方法的典型用法代码示例。如果您正苦于以下问题:PHP User::withTrashed方法的具体用法?PHP User::withTrashed怎么用?PHP User::withTrashed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\User
的用法示例。
在下文中一共展示了User::withTrashed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enable
/**
* Permet de ré-activer un compte
*
* @param Request $request
* @param int $user_id Identifiant utilisateur
* @param string $credentials_hash Hash des credentials de l'utilisateur
* @param string $deleted_at_hash Hash de la date de la désactivation du compte
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function enable(Request $request, $user_id, $credentials_hash, $deleted_at_hash)
{
// Oui, c'est sale, mais c'est pour éviter de dire à un utilisateur malveillant que le compte n'existe pas, existe,
// que c'est le hash des credentials qui est mauvais, ou que c'est le hash du deleted_at qui est mauvais
// Au final, s'il y a une étape qui a merdée, on lui dit juste que la réactivation était impossible. :-)
$error = false;
// On n'oublie pas le withTrashed(), sinon ça ne renvoie rien
$user = User::withTrashed()->find($user_id);
if ($user === null) {
$error = true;
}
if (!$error && ($credentials_hash !== $user->getHashedCredentials() || $deleted_at_hash !== $user->getHashedDeletedAt())) {
$error = true;
}
if ($error) {
$request->session()->flash('message', 'danger|La réactivation de ce compte est impossible.');
} else {
// Réactivation du compte
$user->deleted_at = null;
$user->update();
Auth::loginUsingId($user->id);
$request->session()->flash('message', 'success|Votre compte a été réactivé avec succès !');
}
return redirect(route('index'));
}
示例2: restore
public function restore($id)
{
$specificUser = User::withTrashed()->find($id);
$specificUser->restore();
$users = User::where('admin1_user0', '=', 0)->withTrashed()->get();
return Redirect::to('dashboard')->with('users', $users);
}
示例3: restore
/**
* @param string $hash
* @return \Illuminate\Http\RedirectResponse
*/
public function restore($hash)
{
$user = $this->user->withTrashed()->byHash($hash);
$user->restore();
$message = trans('blogify::notify.success', ['model' => 'Post', 'name' => $user->fullName, 'action' => 'restored']);
session()->flash('notify', ['success', $message]);
return redirect()->route('admin.users.index');
}
示例4: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
if ($this->checkauth(9)['err'] == 1) {
return $this->checkauth(9)['view'];
}
$div = User::withTrashed()->orderBy('email')->paginate(20);
return view('admin.users.all')->withData($div);
}
示例5: index
public function index()
{
$buyer = null;
$seller = null;
$maxSale = Sales::addSelect('items.id AS id', 'items.name AS name', 'bids.price AS price', 'bids.user_id AS buyer_id', 'items.user_id AS seller_id')->join('bids', 'sales.bid_id', '=', 'bids.id')->join('items', 'bids.item_id', '=', 'items.id')->orderBy('bids.price', 'desc')->first();
if ($maxSale !== null) {
$buyer = User::withTrashed()->find($maxSale->buyer_id);
$seller = User::withTrashed()->find($maxSale->seller_id);
}
return view('index')->with(compact('maxSale', 'buyer', 'seller'));
}
示例6: findOrThrowException
/**
* @param $id
* @param bool $withRoles
* @return mixed
* @throws GeneralException
*/
public function findOrThrowException($id, $withRoles = false)
{
if ($withRoles) {
$user = User::with('roles')->withTrashed()->find($id);
} else {
$user = User::withTrashed()->find($id);
}
if (!is_null($user)) {
return $user;
}
throw new GeneralException('That user does not exist.');
}
示例7: testUserRestore
public function testUserRestore()
{
$UserAdmin = \App\User::whereHas('role', function ($q) {
$q->where('admin', true);
})->first();
$this->be($UserAdmin);
$User = \App\User::create(['email' => str_random(5) . '@' . str_random(3) . '.com']);
$id = $User->id;
$User = \App\User::withTrashed()->where('id', $id)->first();
$this->call('GET', route('admin.users.restore', $User->id));
$User->forceDelete();
$this->assertRedirectedToRoute('admin.users.list');
}
示例8: setUp
public function setUp()
{
parent::setUp();
static::$userData = ['username' => 'test', 'password' => base64_encode('123'), 'language_id' => 1, 'country_id' => 1];
$user = \App\User::withTrashed()->where('username', '=', 'test')->first();
if (!$user) {
$user = factory(\App\User::class)->create(static::$userData);
}
if ($user->trashed()) {
$user->restore();
}
static::$idUser = $user->id;
}
示例9: setUp
public function setUp()
{
parent::setUp();
static::$userData = ['username' => 'test', 'password' => base64_encode('123'), 'language_id' => 1, 'country_id' => 1];
$user = \App\User::withTrashed()->where('username', '=', 'test')->first();
if (!$user) {
$user = factory(\App\User::class)->create(static::$userData);
}
if ($user->trashed()) {
$user->restore();
}
static::$idUser = $user->id;
static::$headers = array('Content-Type' => 'application/json', 'Authorization' => 'Bearer ' . Token::createToken($user));
$this->taskData['user_id'] = $user->id;
}
示例10: findByEmailOrCreate
public function findByEmailOrCreate($userData, $ip)
{
$name = explode(' ', $userData->name);
$user_exist = User::withTrashed()->where('ip', $ip)->first();
if ($user_exist != null) {
Image::where('ip', $ip)->delete();
$user_exist->delete();
Session::flash('message', "No cheating bro!! You're disqualified now!! ");
Session::flash('alert-class', 'error');
return 'user exist';
} else {
$user = User::create(['username' => $name, 'first_name' => $name[0], 'last_name' => $name[1], 'email' => $userData->email, 'role' => 1, 'ip' => $ip]);
Session::flash('message', 'Welcome, ' . $user->first_name . ' ' . $user->last_name);
return $user;
}
}
示例11: index
public function index(Request $request)
{
$query = Revision::orderBy('created_at', 'desc');
$search = [];
$search['local'] = $request->input('local', '');
$search['user_id'] = $request->input('user_id', '');
$search['id'] = $request->input('id', '');
$search['start_date'] = $request->input('start_date', '');
$search['end_date'] = $request->input('end_date', '');
$search['local'] ? $query->where('revisionable_type', $search['local']) : '';
$search['user_id'] ? $query->where('user_id', $search['user_id']) : '';
$search['id'] ? $query->where('revisionable_id', $search['id']) : '';
$search['start_date'] ? $query->where('created_at', '>=', Carbon::createFromFormat('d/m/Y H:i', $search['start_date'])->format('Y-m-d H:i') . ':00') : '';
$search['end_date'] ? $query->where('created_at', '<=', Carbon::createFromFormat('d/m/Y H:i', $search['end_date'])->format('Y-m-d H:i') . ':59') : '';
$revisions = $query->paginate(50);
$view['search'] = $search;
$view['revisions'] = $revisions;
$view['alias'] = config('maudit.alias');
$view['users'] = User::withTrashed()->get()->pluck('name', 'id')->toArray();
return view('mixdinternet/maudit::admin.index', $view);
}
示例12: index
public function index()
{
if (!Auth::user()->almighty) {
return redirect('/');
}
$users = User::withTrashed()->orderBy('verified', 'desc')->orderBy('deleted_at');
switch ($_REQUEST['sort']) {
case 'first_name':
$users = User::orderBy('forename');
break;
case 'last_name':
$users = User::orderBy('lastname');
}
$users = $users->get();
$verified_users = $users->filter(function ($user) {
return $user->verified;
});
$disabled_users = $users->filter(function ($user) {
return $user->trashed();
});
return view('users.index', compact('users', 'verified_users', 'disabled_users'));
}
示例13: restore
/**
* @param $id
* @return \Illuminate\Http\RedirectResponse
*/
public function restore($id)
{
User::withTrashed()->where('id', $id)->restore();
Session::flash('message', 'Se han recuperado los datos!');
return redirect()->route('usuarios.show', $id);
}
示例14: index
public function index()
{
$users = User::withTrashed()->paginate(15);
return view('admin.user')->withUsers($users);
}
示例15: list_results
/**
* Get a list of ladder match results for the user and also works out the game scores for the user and opponent.
* @param array $array An array of results from the Results Table.
* @return array An array of results, including the related booking information.
*/
private function list_results($array)
{
foreach ($array as $match) {
$booking = Booking::find($match->match_id);
$opponent = $booking->player2_id;
$user = \Auth::user()->id;
$opponent = $opponent == $user ? User::withTrashed()->find($booking->player1_id) : User::withTrashed()->find($booking->player2_id);
$match['opponent'] = $opponent->first_name;
$opponent_points = Result::where('match_id', '=', $match->match_id)->where('player_id', '=', $opponent->id)->pluck('points');
$match['opponent_games'] = $this->game_score($opponent_points, $match->points);
$match['user_games'] = $this->game_score($match->points, $opponent_points);
}
return $array;
}