update: add commission history pagination

This commit is contained in:
tokumeikoi 2022-08-10 01:31:20 +08:00
parent 724abdd49f
commit 446d16c7da
2 changed files with 18 additions and 11 deletions

View File

@ -27,8 +27,9 @@ class InviteController extends Controller
public function details(Request $request) public function details(Request $request)
{ {
return response([ $current = $request->input('current') ? $request->input('current') : 1;
'data' => CommissionLog::where('invite_user_id', $request->user['id']) $pageSize = $request->input('page_size') >= 10 ? $request->input('page_size') : 10;
$builder = CommissionLog::where('invite_user_id', $request->user['id'])
->where('get_amount', '>', 0) ->where('get_amount', '>', 0)
->select([ ->select([
'id', 'id',
@ -37,7 +38,13 @@ class InviteController extends Controller
'get_amount', 'get_amount',
'created_at' 'created_at'
]) ])
->get() ->orderBy('created_at', 'DESC');
$total = $builder->count();
$details = $builder->forPage($current, $pageSize)
->get();
return response([
'data' => $details,
'total' => $total
]); ]);
} }

File diff suppressed because one or more lines are too long