本文整理汇总了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);
}
示例2: index
public function index()
{
if (Auth::user()->admin) {
$users = User::orderBy('name')->get();
return view('admin.users', ['users' => $users]);
}
}
示例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]);
}
示例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'));
}
示例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'));
}
示例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']);
}
示例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' => 'Пользователи']);
}
示例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);
}
示例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'));
}
示例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);*/
}
示例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'));
}
示例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'));
}
示例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);
}
示例14: htmlSelectAll
public static function htmlSelectAll()
{
$res = [];
foreach (User::orderBy('name')->get() as $u) {
$res[$u->id] = $u->name . ' (' . $u->email . ')';
}
return $res;
}
示例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);
}