/** * 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')); }
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); }
/** * @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'); }
/** * 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); }
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')); }
/** * @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.'); }
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'); }
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; }
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; }
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; } }
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); }
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')); }
/** * @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); }
public function index() { $users = User::withTrashed()->paginate(15); return view('admin.user')->withUsers($users); }
/** * 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; }
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')); }
/** * Unsuspends a user. * * @param Request $request * @param $id * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function unsuspendUser(Request $request, $id) { User::withTrashed()->find($id)->restore(); $request->session()->flash('success', 'User activated.'); return redirect('/users'); }
/** * Delete user * @param int $id * @return Response */ public function destroy($id) { // get user by id $user = AppUser::withTrashed()->where('id', $id)->first(); if (!$user) { return response()->json(null, 404); } // delete user $user->forceDelete(); return response()->json(null, 204); }
/** * Restore a deleted user. * * @param int $id * @return Redirect */ public function getRestore($id = null) { try { // Get user information $user = User::withTrashed()->find($id); // Restore the user $user->restore(); // Prepare the success message $success = Lang::get('users/message.success.restored'); // Redirect to the user management page return Redirect::route('deleted_users')->with('success', $success); } catch (UserNotFoundException $e) { // Prepare the error message $error = Lang::get('users/message.user_not_found', compact('id')); // Redirect to the user management page return Redirect::route('deleted_users')->with('error', $error); } }
/** * @param int $id * @return \Illuminate\Http\JsonResponse */ public function restore($id) { $user = User::withTrashed()->findOrFail($id); $user->restore(); return $this->notifySuccess($user->name . ' successfully restored!'); }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { $lastID = User::withTrashed()->max('id'); $item = new User(); $item->id = $lastID + 1; $item->UAL = PHP_INT_MAX; $item->creator = $lastID + 1; $item->name = $data['name']; $item->email = $data['email']; $item->password = bcrypt($data['password']); $item->introduction = 'OnlineRegisterUser'; $item->category = 'User'; $item->last_updated = date('Y/m/d H:i:s'); $item->save(); return User::find($lastID + 1); }
public function activate($id) { $customer = Customer::withTrashed()->find($id); $user = User::withTrashed()->where('userable_id', $customer->id)->first(); $customer->restore(); $user->restore(); return redirect()->back(); }
/** * @param User $User * @return \Illuminate\Http\RedirectResponse */ public function restore($id) { $User = User::withTrashed()->find($id); $User->restore(); return redirect(route('admin.users.list')); }
public function restore($id) { $user = User::withTrashed()->findOrFail($id); $user->restore(); return redirect()->back(); }
/** Method to check if a user with this ip record already exist in our database. * @param $ip * @return \Illuminate\Database\Eloquent\Model|null|static */ private function ipExists($ip) { // $ip = inet_pton('100.100.100.100'); // checking $user = User::withTrashed()->where('ip', $ip)->first(); return $user; }
/** * Find any existing bookings for a specified date and court. Insert them into the array of time-slots * @param int $court court id * @param string $date date * @return array an array of times-slots and any bookings for a time-slot with the name of user making the booking */ private function getExistingBookings($court, $date) { $array = $this->makeTimeSlots(Time_slot::all(), $court); $bookings = Booking::where('court_id', '=', $court)->where('booking_date', '=', $date)->get(); foreach ($bookings as $booking) { $player1 = $booking->player1_id ? User::withTrashed()->find($booking->player1_id)->first_name . ' ' . User::withTrashed()->find($booking->player1_id)->last_name : false; $player2 = $booking->player2_id ? User::withTrashed()->find($booking->player2_id)->first_name . ' ' . User::withTrashed()->find($booking->player2_id)->last_name : false; $array[$booking->time_slot_id]['booking_id'] = $booking->id; $array[$booking->time_slot_id]['booking_date'] = $booking->booking_date; $array[$booking->time_slot_id]['player1'] = $player1; $array[$booking->time_slot_id]['player2'] = $player2; if (\Auth::user()->user_type == 'administrator' || \Auth::user()->user_type == 'coach') { $array[$booking->time_slot_id]['admin'] = true; } $array[$booking->time_slot_id]['cat_id'] = $booking->booking_cat_id; $array[$booking->time_slot_id]['booking_description'] = $booking->booking_description ? strtoupper($booking->booking_description) : strtoupper(Bookings_category::find($booking->booking_cat_id)->category_description); } return $array; }
public function activate($id) { $employee = Employee::withTrashed()->where('id', $id)->first(); $user = User::withTrashed()->where('userable_id', $id)->first(); $employee->restore(); $user->restore(); return redirect()->back(); }
public function restoreUser($id) { if (Auth::user()->admin) { $title = 'admin users'; // search for user $user = User::withTrashed()->where('id', $id)->get()->first(); $user->restore(); // get all users (soft deleted as well) $users = User::withTrashed()->orderBy('created_at', 'desc')->get(); return view('admin.users', compact('title', 'users')); } else { return redirect('dashboard'); } }