|
|
@@ -72,29 +72,24 @@ class BackflowService extends BaseService
|
|
|
|
|
|
public static function paginate(array $search = []): array
|
|
|
{
|
|
|
- $date = Carbon::now('Asia/Shanghai')->format('Y-m');
|
|
|
- $query = static::$MODEL::where(static::getWhere($search));
|
|
|
-
|
|
|
-// ->where('date', '<', $date)
|
|
|
|
|
|
|
|
|
- if (isset($search['username']) && !empty($search['username'])) {
|
|
|
- $username = $search['username'];
|
|
|
- $query->whereHas('user', function ($query) use ($username) {
|
|
|
+ $page = request()->input('page', 1);
|
|
|
+ $limit = request()->input('limit', 10);
|
|
|
+ $date = Carbon::now('Asia/Shanghai')->format('Y-m');
|
|
|
+ $query = static::$MODEL::where(BetService::getWhere($search))
|
|
|
+ ->where('date', '<', $date)
|
|
|
+ ;
|
|
|
+ if (isset($params['username']) && !empty($params['username'])) {
|
|
|
+ $username = $params['username'];
|
|
|
+ $query = $query->whereHas('user', function ($query) use ($username) {
|
|
|
$query->where('username', $username);
|
|
|
});
|
|
|
}
|
|
|
+ $count = $query->count();
|
|
|
+ $query->with(['user'])->orderByDesc('date')->orderBy('status');
|
|
|
+ $list = $query->forPage($page, $limit)->get()->toArray();
|
|
|
|
|
|
-
|
|
|
- $query->with(['user'])
|
|
|
- ->orderByDesc('date')
|
|
|
- ->orderBy('status');
|
|
|
-
|
|
|
-// $paginator = $query->paginate($limit);
|
|
|
-
|
|
|
- $total = $query->count();
|
|
|
- $list = $query->forPage($search['page'], $search['limit'])->get()->toArray();
|
|
|
-
|
|
|
- return ['total' => $total, 'data' => $list];
|
|
|
+ return ['total' => $count, 'data' => $list];
|
|
|
}
|
|
|
}
|