当前位置: 首页>>代码示例>>PHP>>正文


PHP User::orderBy方法代码示例

本文整理汇总了PHP中app\models\User::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP User::orderBy方法的具体用法?PHP User::orderBy怎么用?PHP User::orderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\User的用法示例。


在下文中一共展示了User::orderBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // Busca no banco de dados os todos users, ordenados pelo nome e cria paginação
     $users = User::orderBy('name')->paginate(10);
     // Retorna a view com os users
     return view('users.index', compact('users'));
 }
开发者ID:rjunioramorim,项目名称:helpdesk,代码行数:12,代码来源:UsersController.php

示例2: edit

 public function edit(Request $request, $id)
 {
     $users = User::orderBy('created_at', 'DESC')->paginate(7);
     $page_title = 'Edit User';
     $user = User::findOrFail($id);
     return view('admin.users.edit', compact('users', 'user', 'page_title'));
 }
开发者ID:alfrcr,项目名称:ilearn,代码行数:7,代码来源:UserController.php

示例3: index

 /**
  * Display a listing of the User.
  * GET|HEAD /users
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $offset = $request->page ? $request->page : 1;
     $limit = $request->limit ? $request->limit : 12;
     $offset = ($offset - 1) * $limit;
     $posts = User::orderBy('id', 'desc')->offset($offset)->limit($limit)->get();
     return response()->json($posts);
 }
开发者ID:SawMaineK,项目名称:iwomenapp,代码行数:14,代码来源:UserAPIController.php

示例4: getUsers

 public function getUsers($user_id = null)
 {
     if ($user_id) {
         return view('admin.stat.user_details', ['orders' => Order::where('user_id', $user_id)->paginate(15), 'user' => User::find($user_id)->first()]);
     } else {
         return view('admin.stat.users', ['users' => User::orderBy('email')->paginate(15)]);
     }
 }
开发者ID:venomir,项目名称:tc,代码行数:8,代码来源:StatisticController.php

示例5: show

 /**
  * Shows the details page of a meal
  */
 public function show($id)
 {
     $meal = Meal::find($id);
     if (!$meal) {
         App::abort(404, "Maaltijd niet gevonden");
     }
     return $this->setPageContent(view('meal/show', ['meal' => $meal, 'users' => User::orderBy('name')->get()]));
 }
开发者ID:jakobbuis,项目名称:bolknoms2,代码行数:11,代码来源:ShowMeal.php

示例6: getUsers

 public function getUsers(Request $request)
 {
     if (Session::has('Admin')) {
         $users = User::orderBy('id', 'desc')->paginate(20);
         return view('admin.user', ['users' => $users]);
     } else {
         return redirect("admin");
     }
 }
开发者ID:Thitiwut,项目名称:money-flow,代码行数:9,代码来源:AdminController.php

示例7: index

 public function index()
 {
     $users = User::orderBy('created_at', 'DESC')->paginate(5);
     $majors = Major::orderBy('created_at', 'DESC')->paginate(5);
     $subjects = Subject::orderBy('created_at', 'DESC')->paginate(5);
     $classrooms = Classroom::orderBy('created_at', 'DESC')->paginate(5);
     $announcements = Announcement::orderBy('created_at', 'DESC')->paginate(5);
     return view('admin.home.home', compact('users', 'majors', 'subjects', 'classrooms', 'announcements'));
 }
开发者ID:alfrcr,项目名称:ilearn,代码行数:9,代码来源:HomeController.php

示例8: run

 public function run()
 {
     $faker = Faker\Factory::create();
     DB::table('favorites')->truncate();
     foreach (range(1, 30) as $index) {
         $ads = Advertisement::orderBy(DB::raw('RAND()'))->first();
         User::orderBy(DB::raw('RAND()'))->first()->favorites()->attach($ads->id);
     }
 }
开发者ID:lyovkin,项目名称:v2board,代码行数:9,代码来源:FavoritesTableSeeder.php

示例9: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $users = User::orderBy('seen', 'asc')->orderBy('created_at', 'desc')->paginate($this->itemPerPage);
     $roles = Role::all();
     $counts['total'] = User::count();
     foreach ($roles as $role) {
         $slug = $role->slug;
         $counts[$slug] = User::whereHas('role', function ($q) use($slug) {
             $q->whereSlug($slug);
         })->count();
     }
     return view('admin.users.index', compact('users', 'roles', 'counts'));
 }
开发者ID:doankhoi,项目名称:Application,代码行数:18,代码来源:UserController.php

示例10: getUsers

 /**
  * @param array $options
  * @return mixed
  */
 public function getUsers(array $options)
 {
     // set input options
     $this->setOptions($options);
     // filtration users
     if ($this->type !== 'all') {
         // if needs online users
         if ($this->type == 'online') {
             $this->user->where('status', '=', true);
         } else {
             $this->user->where('status', '=', false);
         }
     }
     // sorted users
     if ($this->sort) {
         if (isset($this->sort['date'])) {
             // sort by date added
             $this->user->orderBy('created_at', $this->sort['date']);
         }
         // sort by username
         if (isset($this->sort['username'])) {
             $this->user->orderBy('username', $this->sort['username']);
         }
         // sort by email
         if (isset($this->sort['email'])) {
             $this->user->orderBy('email', $this->sort['email']);
         }
     }
     // set offset
     if ($this->offset > 0) {
         $this->user->skip($this->offset);
     }
     // get users collection with fields
     $users = $this->user->take($this->limit)->get($this->fields);
     // return collection
     return $users;
 }
开发者ID:tytarenko,项目名称:messager,代码行数:41,代码来源:UsersProvider.php

示例11: index

 public function index()
 {
     $search['text'] = Input::get('search_text');
     $search['type'] = Input::get('search_type');
     if ($search['type'] == 'user') {
         $list = User::User($search['text'])->orderBy('id', 'desc')->paginate(15);
     } else {
         if ($search['type'] == 'email') {
             $list = User::Email($search['text'])->orderBy('id', 'desc')->paginate(15);
         } else {
             $list = User::orderBy('id', 'desc')->paginate(15);
         }
     }
     return View::make('admin.user_list')->withlist($list)->withsearch($search);
 }
开发者ID:snyh,项目名称:just-calc-dstore-info,代码行数:15,代码来源:UserController.php

示例12: index

 /**
  * @param Request $request
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function index(Request $request)
 {
     $users = User::orderBy('id', 'desc');
     if ($request->input('id')) {
         $users = $users->where('id', '=', $request->input('id'));
     }
     if ($request->input('email')) {
         $users = $users->where('email', 'LIKE', '%' . $request->input('email') . '%');
     }
     if ($request->input('user_name')) {
         $users = $users->where('name', 'LIKE', '%' . $request->input('user_name') . '%');
     }
     $users = $users->paginate(10);
     return view('admin.user.index', ['users' => $users, 'f_id' => $request->input('id'), 'f_email' => $request->input('email'), 'f_user_name' => $request->input('user_name')]);
 }
开发者ID:lyovkin,项目名称:elcoinbank,代码行数:19,代码来源:AdminUserController.php

示例13: showList

 public function showList()
 {
     $user = new User();
     $all = $user->orderBy('created_at')->get()->toArray();
     $age_categories = $user->age_categories;
     $belts = $user->belt_colours;
     $weights = $user->weights;
     usort($all, function ($a, $b) {
         $belt_order = array('white', 'blue', 'purple', 'brown', 'black');
         $i1 = array_search($a['belt'], $belt_order);
         $i2 = array_search($b['belt'], $belt_order);
         return $i1 < $i2 ? -1 : 1;
     });
     $data['all'] = $all;
     return view('userlist')->with('data', $data);
 }
开发者ID:roycocup,项目名称:bjjcomp2,代码行数:16,代码来源:UserController.php

示例14: indexAjax

 public function indexAjax(Request $r)
 {
     // Para saber que variables llegan por parte
     // del control DataTable ver:
     // https://datatables.net/manual/server-side
     $limit = $r->input('length', 10);
     $page = $r->input('start') / $limit + 1;
     $column = $r->input('order')[0]['column'];
     $column = $r->input('columns')[$column]['data'];
     $direction = $r->input('order')[0]['dir'];
     $pattern = $r->input('search')['value'];
     // select *
     // from users
     // where email like '%algunapatron%'
     // order by [columna] asc|desc
     $users = User::orderBy($column, $direction)->where('email', 'like', "%{$pattern}%")->paginate($limit, ['*'], 'start', $page);
     $result = ['draw' => $r->input('draw'), 'recordsTotal' => $users->total(), 'recordsFiltered' => $users->total(), 'data' => $users->all()];
     return response()->json($result);
 }
开发者ID:sguillen-proyectos,项目名称:laravel_training,代码行数:19,代码来源:UserController.php

示例15: index

 public function index()
 {
     $name = Input::get('name', '');
     $email = Input::get('email', '');
     $onlyActive = Input::get('only_active', '');
     $perPage = Input::get('per_page', 50);
     $users = User::orderBy('created_at');
     $users->whereRole('user');
     if ($name) {
         $users->where('name', 'like', '%' . $name . '%');
     }
     if ($email) {
         $users->where('email', 'like', '%' . $email . '%');
     }
     if ($onlyActive) {
         $users->where('is_active', 1);
     }
     $users = $users->with('profile')->paginate($perPage);
     return view('admin.pages.user.index', compact('users', 'onlyActive', 'name', 'email'));
 }
开发者ID:blozixdextr,项目名称:adtw,代码行数:20,代码来源:UserController.php


注:本文中的app\models\User::orderBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。