mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
add sorter
This commit is contained in:
parent
ab97db552d
commit
5bc4bff8f9
@ -15,10 +15,14 @@ class UserController extends Controller
|
||||
{
|
||||
$current = $request->input('current') ? $request->input('current') : 1;
|
||||
$pageSize = $request->input('pageSize') >= 10 ? $request->input('pageSize') : 10;
|
||||
$sortType = $request->input('sort_type') ? 'ASC' : 'DESC';
|
||||
$userModel = User::orderBy('created_at', 'DESC');
|
||||
if ($request->input('email')) {
|
||||
$userModel->where('email', $request->input('email'));
|
||||
}
|
||||
if ($request->input('sort')) {
|
||||
$userModel->orderBy($request->input('sort'), $sortType);
|
||||
}
|
||||
$total = $userModel->count();
|
||||
$res = $userModel->forPage($current, $pageSize)
|
||||
->get();
|
||||
|
Loading…
Reference in New Issue
Block a user