當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::orderBy方法代碼示例

本文整理匯總了PHP中app\User::orderBy方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::orderBy方法的具體用法?PHP User::orderBy怎麽用?PHP User::orderBy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\User的用法示例。


在下文中一共展示了User::orderBy方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: lists

 /**
  * 獲取賬戶列表.
  *
  * @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);
 }
開發者ID:zenoZz,項目名稱:laravelapi,代碼行數:37,代碼來源:UserRepository.php

示例2: index

 public function index()
 {
     if (Auth::user()->admin) {
         $users = User::orderBy('name')->get();
         return view('admin.users', ['users' => $users]);
     }
 }
開發者ID:edilsonribeiro,項目名稱:etec.palmital.quati,代碼行數:7,代碼來源:UserController.php

示例3: postIndex

 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]);
 }
開發者ID:bsmitty54,項目名稱:P4,代碼行數:26,代碼來源:UserController.php

示例4: edit

 /**
  * 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'));
 }
開發者ID:JohanArmando,項目名稱:MaxCorpMedia,代碼行數:13,代碼來源:WebController.php

示例5: index

 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'));
 }
開發者ID:Panfen,項目名稱:mango,代碼行數:27,代碼來源:HomeController.php

示例6: create

 /**
  * 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']);
 }
開發者ID:huludini,項目名稱:aura-kingdom-web,代碼行數:13,代碼來源:AuthController.php

示例7: index

 /**
  * 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' => 'Пользователи']);
 }
開發者ID:errogaht,項目名稱:bv-table,代碼行數:12,代碼來源:UserController.php

示例8: getTeam

 public function getTeam(Request $request)
 {
     if ($request->ajax() || $request->wantsJson) {
         return User::orderBy('lastname')->orderBy('firstname')->get(['firstname', 'lastname', 'email', 'id']);
     }
     abort(404);
 }
開發者ID:patrikkernke,項目名稱:basecamp,代碼行數:7,代碼來源:TeamController.php

示例9: index

 /**
  * 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'));
 }
開發者ID:trongtri0705,項目名稱:staff,代碼行數:12,代碼來源:StaffController.php

示例10: index

 /**
  * 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);*/
 }
開發者ID:Helg18,項目名稱:mailer_laravel,代碼行數:12,代碼來源:UsersController.php

示例11: edit

 /**
  * 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'));
 }
開發者ID:bigDeacs,項目名稱:bunbury,代碼行數:12,代碼來源:ArticlesController.php

示例12: users

 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'));
 }
開發者ID:suhairi,項目名稱:keuntungan,代碼行數:7,代碼來源:PresetController.php

示例13: destroy

 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);
 }
開發者ID:Rodieche,項目名稱:catalogo_web,代碼行數:8,代碼來源:UsersController.php

示例14: htmlSelectAll

 public static function htmlSelectAll()
 {
     $res = [];
     foreach (User::orderBy('name')->get() as $u) {
         $res[$u->id] = $u->name . ' (' . $u->email . ')';
     }
     return $res;
 }
開發者ID:jonasdahl,項目名稱:mammeriet,代碼行數:8,代碼來源:User.php

示例15: index

 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);
 }
開發者ID:rikardote,項目名稱:agenda,代碼行數:8,代碼來源:RegistroController.php


注:本文中的app\User::orderBy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。