Example #1
0
 /**
  * 获取账户列表.
  *
  * @param int $pageSize 分页大小
  *
  * @return \Illuminate\Pagination\Paginator
  */
 public function lists($filter, $sorter, $page, $pageSize)
 {
     //        $user = DB::table('users');
     //        /*
     //     * 构建过滤条件
     //     */
     //        if (is_array($filter) && count($filter) > 0) {
     //
     //            foreach ( $filter as $key => $value ) {
     //
     //                //用户名
     //                if (strcasecmp($key, 'username') == 0 ) {
     //                    $user->where('username', 'LIKE', "%{$value}%");
     //                }
     //
     //            }
     //        }
     //
     //        //构建排序条件
     //        if (is_array($sorter) && count($sorter) > 0) {
     //            foreach ($sorter as $key => $value) {
     //                //ID排序
     //                if (strcasecmp($key, 'ID') == 0) {
     //                    $sort = $value ? 'asc' : 'desc';
     //                    $user->orderBy('id', $sort);
     //                }
     //            }
     //        }
     return $this->model->orderBy('id', 'desc')->paginate($pageSize);
 }
 public function index()
 {
     if (Auth::user()->admin) {
         $users = User::orderBy('name')->get();
         return view('admin.users', ['users' => $users]);
     }
 }
Example #3
0
 public function postIndex(Request $request)
 {
     // first retrieve the user list
     $users = \App\User::orderBy('last_name')->orderBy('first_name')->get();
     // now filter the collection as needed based on user input
     //first filter on name / email if user entered a string
     $umatch = strtolower($request->input('user'));
     if (isset($umatch) && $umatch != '') {
         $filtered = $users->filter(function ($item) use($umatch) {
             return is_int(strpos(strtolower($item->last_name), $umatch)) || is_int(strpos(strtolower($item->email), $umatch));
         });
         $users = $filtered;
     }
     // now filter by category
     $role = $request->input('role');
     if (isset($role) && $role != '') {
         $filtered = $users->filter(function ($item) use($role) {
             return $item->role == $role;
         });
         $users = $filtered;
     }
     // now return the view with the filtered list
     $request->session()->put('users', $users);
     $ucol = $request->session()->get('ucol');
     return view('users', ['sortOrder' => $ucol], ['users' => $users]);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $web = Web::find($id);
     $users = User::orderBy('nombre')->lists('nombre', 'id');
     $categorias = Category::orderBy('nombre')->lists('nombre', 'id');
     return view('admin.web.edit', compact('web', 'users', 'categorias'));
 }
Example #5
0
 public function index()
 {
     $user = \Auth::user();
     $time = $this->formatDate();
     $action = 'home';
     $r = Signin::where('user_id', \Auth::user()->id)->first();
     $count = 0;
     $signined = false;
     if ($r) {
         $count = $r['count'];
         if (substr(Carbon::now(), 0, 10) == substr($r['last_signin'], 0, 10)) {
             $signined = true;
         }
     }
     $signinList = Signin::where('last_signin', 'like', substr(Carbon::now(), 0, 10) . '%')->orderBy('last_signin', 'desc')->get();
     foreach ($signinList as &$item) {
         $item['last_signin'] = substr($item['last_signin'], 11, 8);
     }
     $cates = Cate::orderBy('count', 'desc')->limit(6)->get();
     $authors = User::orderBy('score', 'desc')->limit(6)->get();
     $teams = Team::limit(3)->get();
     $recommendedArticles = Article::orderBy('recommend', 'deac')->limit(4)->get();
     $phpArticles = Article::where('cate_id', 1)->limit(5)->get();
     $todayHotArticles = Article::where('published_at', '>=', Carbon::now()->subDay(1))->where('published_at', '<=', Carbon::now())->orderBy('view', 'deac')->limit(6)->get();
     $weekHotArticles = Article::where('published_at', '>=', Carbon::now()->subDay(7))->where('published_at', '<=', Carbon::now())->orderBy('view', 'deac')->limit(6)->get();
     return view('home', compact('user', 'time', 'action', 'signin', 'minus', 'count', 'signined', 'signinList', 'cates', 'authors', 'teams', 'recommendedArticles', 'phpArticles', 'todayHotArticles', 'weekHotArticles'));
 }
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $new_id = User::all()->count() > 0 ? User::orderBy('id', 'desc')->first()->id + 1 : 2400;
     DB::connection('member')->table('tb_user')->insert(['mid' => $data['name'], 'password' => $data['password'], 'pwd' => Hash::make($data['password']), 'idnum' => $new_id]);
     DB::connection('account')->table('accounts')->insert(['id' => $new_id, 'username' => $data['name'], 'password' => $data['password']]);
     return User::create(['id' => $new_id, 'username' => $data['name'], 'password' => Hash::make($data['password']), 'role' => 'member']);
 }
Example #7
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if (!\Auth::getUser()->is_admin) {
         return redirect(route('profile'));
     }
     return view('user/index')->with(['list' => \App\User::orderBy('is_active', 'ASC')->orderBy('is_admin', 'DESC')->orderBy('name', 'ASC')->paginate(20), 'page_title' => 'Пользователи']);
 }
Example #8
0
 public function getTeam(Request $request)
 {
     if ($request->ajax() || $request->wantsJson) {
         return User::orderBy('lastname')->orderBy('firstname')->get(['firstname', 'lastname', 'email', 'id']);
     }
     abort(404);
 }
Example #9
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $title = "Staff";
     $data = User::orderBy('id', 'desc')->get();
     return view('html.staff.list', compact('data', 'title'));
 }
Example #10
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $users = User::orderBy('id', 'ASC')->paginate(10);
     return view('admin.users.index')->with('users', $users);
     /*$users = User::orderBy('id', 'ASC')->paginate(5);
       return view('admin.users.index')->with('users', $users);*/
 }
Example #11
0
 /**
  * Show the form for creating a new Cruiseline.
  *
  * @return View
  */
 public function edit($id)
 {
     $article = Article::find($id);
     $tags = Tag::lists('name', 'id');
     $users = User::orderBy('name', 'ASC')->lists('name', 'id');
     return view('articles.edit', compact('article', 'tags', 'users'));
 }
Example #12
0
 public function users()
 {
     $users = User::orderBy('level_id', 'asc')->get();
     $level = Level::lists('name', 'id');
     $ppk = Ppk::lists('name', 'id');
     return View('admin.preset.users', compact('users', 'level', 'ppk'));
 }
Example #13
0
 public function destroy($id)
 {
     $user = User::find($id);
     $user->delete();
     Flash::warning('El usuario ' . $user->name . ' ha sido eliminado de forma exitosa');
     $users = User::orderBy('id', 'ASC')->paginate(10);
     return view('admin.users.index')->with('users', $users);
 }
Example #14
0
 public static function htmlSelectAll()
 {
     $res = [];
     foreach (User::orderBy('name')->get() as $u) {
         $res[$u->id] = $u->name . ' (' . $u->email . ')';
     }
     return $res;
 }
Example #15
0
 public function index()
 {
     if (!\Auth::user()->admin()) {
         return redirect()->route('agenda.index');
     }
     $users = User::orderBy('type', 'DESC')->orderBy('name', 'ASC')->get();
     return view('admin.users.index')->with('users', $users);
 }
Example #16
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     /* $users = User::all();
        $listings = Listing::all();*/
     $users = User::orderBy('created_at', 'desc')->limit(10)->get();
     $listings = Listing::orderBy('created_at', 'desc')->limit(10)->get();
     return view('admin.page.index', compact('users', 'listings'));
 }
Example #17
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $users = User::orderBy('created_at', 'asc')->get();
     $templates = Template::orderBy('created_at', 'asc')->get();
     $i = 0;
     return view('admin.index', ['users' => $users, 'templates' => $templates, 'i' => $i]);
 }
Example #18
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $user = Auth::user();
     $user_name = $user->name;
     $bank = Bank::where('name', '=', $user_name)->first();
     $users = User::orderBy('money', 'desc')->take(5)->get();
     return view('bank.bank', compact('user', 'user_name', 'bank', 'users'));
 }
Example #19
0
 /**
  * Display a listing of the resource.
  *@param Request $request
  * @return Response
  */
 public function getIndex(Request $request)
 {
     $mod = User::orderBy('created_at', 'desc');
     $this->userSearch($mod, $request);
     $users = $mod->paginate(15);
     $this->assign('users', $users);
     return $this->display('admin.user.index');
 }
Example #20
0
 public function lastUpdated()
 {
     $query = User::orderBy('updated_at', 'DESC')->first();
     if ($query) {
         return $query->updated_at->format('Y-m-d H:i:s');
     }
     return date("Y-m-d H:i:s");
 }
Example #21
0
 public function getUsersWithPaginate(Request $request)
 {
     $perPage = $request->get('num');
     if (!is_numeric($perPage) || $perPage < 1 || $perPage > 30) {
         $perPage = 15;
     }
     $users = User::orderBy('id', 'desc')->paginate($perPage);
     return $this->buildResponse(trans('api.user.paginate.success'), Tools::toArray($users));
 }
Example #22
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(City $city)
 {
     $users = User::orderBy('name_first', 'asc')->where('city_id', '=', $city->id)->get();
     foreach ($users as $user) {
         $user->user_events_count = Event::futureEventsByCityId($city->id)->where('user_id', '=', $user->id)->count();
     }
     $users->sortBy('user_events_count');
     return view('users.index', compact('users'));
 }
 public function getSuggestions(Request $request)
 {
     $username = $request->username;
     try {
         //$user1ID = User::where('username', $username)->get();
         //return response()->json(['status' => 200, 'suggestions' => $user1ID], 200);
         $userId = User::where('username', $username)->get(['id'])[0]->id;
         $userPreferences = self::userPreferences($userId);
         $orientation = User::where('username', $username)->get()[0]->orientation;
         $gender = User::where('username', $username)->get()[0]->gender;
         $location = $userPreferences[0]->location;
         $minage = $userPreferences[0]->mixage;
         $maxage = $userPreferences[0]->maxage;
         $status = $userPreferences[0]->status;
         $shortterm = $userPreferences[0]->shortterm;
         $longterm = $userPreferences[0]->longtterm;
         $causalsex = $userPreferences[0]->casualsex;
         //$result = User::orderBy(\DB::raw('RAND()'))->limit(3)->get();
         $users = User::orderBy(\DB::raw('RAND()'))->limit(3)->get();
         $suggestedUsers = [];
         foreach ($users as $user) {
             //changed id ///
             $id = 1;
             $takenUserPreferences = self::userPreferences($id);
             $usernameT = User::where('id', $id)->get()[0]->username;
             $orientationT = User::where('id', $id)->get()[0]->orientation;
             $genderT = User::where('id', $id)->get()[0]->gender;
             if ($orientation == $orientationT && $gender == $genderT && $username == $usernameT) {
                 break;
             }
             $locationT = $takenUserPreferences[0]->location;
             $minageT = $takenUserPreferences[0]->mixage;
             $maxageT = $takenUserPreferences[0]->maxage;
             $statusT = $takenUserPreferences[0]->status;
             $shorttermT = $takenUserPreferences[0]->shortterm;
             $longtermT = $takenUserPreferences[0]->longterm;
             $causalsexT = $takenUserPreferences[0]->casualsex;
             $locationMatch = self::matchLocation($userId, $id, $location, $locationT);
             $ageMatch = self::matchAge($minage, $maxage, $minageT, $maxageT);
             $statusMatch = self::matchStatus($status, $statusT);
             $shortTermMatch = self::matchLongTermRel($shortterm, $shorttermT);
             $longTermMatch = self::matchShortTermRel($longterm, $longtermT);
             $casualSexMatch = self::matchCasualSex($causalsex, $causalsexT);
             $matchPercentage = self::calculateMatchPercentage($locationMatch, $ageMatch, $statusMatch, $longTermMatch, $shortTermMatch, $casualSexMatch);
             if ($matchPercentage >= 0.45) {
                 array_push($suggestedUsers, $user);
             }
         }
         if ($suggestedUsers) {
             return response()->json(['status' => 200, 'suggestions' => $suggestedUsers], 200);
         } else {
             return response()->json(['status' => 200, 'suggestions' => null], 200);
         }
     } catch (Illuminate\Database\QueryException $e) {
         return response()->json(['status' => 200], 200);
     }
 }
Example #24
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     if (Request::isMethod('get')) {
         $users = User::orderBy('id', 'desc')->paginate(50);
         return view('admin.users.list', array('users' => $users));
     }
     $idUser = Request::input('data');
     User::destroy($idUser);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $multas = Multa::orderBy('descripcion', 'ASC')->lists('descripcion', 'id');
     $usuarios = User::orderBy('nombre', 'ASC')->lists('nombre', 'id');
     $estados = Estado::orderBy('descripcion', 'ASC')->lists('descripcion', 'id');
     $libros = Libro::orderBy('nombre', 'ASC')->lists('nombre', 'id');
     $prestamo = Prestamo::find($id);
     return view('admin.prestamos.edit')->with('multas', $multas)->with('usuarios', $usuarios)->with('estados', $estados)->with('libros', $libros)->with('prestamo', $prestamo);
 }
 public function index()
 {
     if (Gate::denies('user-list')) {
         abort(403);
     }
     $usuarios = User::orderBy('name', 'asc')->get();
     return $usuarios;
     //return User::all();
 }
Example #27
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // mirar aquí: http://laravel.com/docs/5.1/pagination
     $users = User::orderBy('id', 'ASC')->paginate(5);
     // para pasar datos a una vista, 2 formas:
     //return view('admin.users.index', $users);
     return view('admin.users.index')->with('users', $users);
     // esta sería la opción recomendada.
 }
 public function listagem()
 {
     /**
      * Usando a Trait PageHeaderTrait,  retorna o nome do Título da Pagina e sua descrição no topo da mesma
      */
     $headerInfo = $this->headerPageName(Route::currentRouteName());
     $usuarios = User::orderBy('name', 'asc')->get();
     return view('usuarios.listagem', compact('usuarios', 'headerInfo'));
 }
Example #29
0
File: User.php Project: oredla/p4
 public static function usersForDropdown()
 {
     $users = \App\User::orderBy('name', 'ASC')->get();
     $users_for_dropdown = [];
     foreach ($users as $user) {
         $users_for_dropdown[$user->id] = $user->name;
     }
     return $users_for_dropdown;
 }
Example #30
0
 public function rank($useId)
 {
     $users = User::orderBy('score', 'desc')->get();
     foreach ($users as $key => $user) {
         if ($user->id == $useId) {
             return $key + 1;
         }
     }
 }