本文整理汇总了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'));
}
示例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'));
}
示例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);
}
示例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)]);
}
}
示例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()]));
}
示例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");
}
}
示例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'));
}
示例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);
}
}
示例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'));
}
示例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;
}
示例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);
}
示例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')]);
}
示例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);
}
示例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);
}
示例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'));
}