diff --git a/app/controller/CustomerController.php b/app/controller/CustomerController.php index b1c9e14..b19d9cb 100644 --- a/app/controller/CustomerController.php +++ b/app/controller/CustomerController.php @@ -66,20 +66,31 @@ class CustomerController public function waitFollow(Request $request) { $userId = $request->user['id']; + $filter = Util::getParam($request, 'filter'); + $page = $request->input('page', 1); + $perPage = $request->input('per_page', 10); $where = [ ['user_id', '=', $userId], ['follow_next', '<>', 0], -// ['follow_next', '<=', time() + 3600 * 24], -// ['follow_next', '>', time()], -// ['warn', '<', 1] ]; - $customer = Customer::where($where)->whereNotNull('follow_next')->orderBy('follow_next')->get(); + + if($filter == 0){ + $where[] = ['follow_next', '<=', time() + 3600 * 24]; + }elseif($filter == 1){ + $where[] = ['follow_next', '<=', time() + 3600 * 24*3]; + }elseif($filter == 2){ + $where[] = ['follow_next', '<=', time() + 3600 * 24*7]; + } + $customer = Customer::where($where) + ->whereNotNull('follow_next') + ->orderBy('follow_next') + ->paginate($perPage, ['*'], 'page', $page); foreach ($customer as &$item) { $item['follow_remaining'] = $item->follow_next-time(); $item['follow_next'] = date('Y-m-d H:i:s',$item->follow_next); } - return Util::success($customer,trans('success')); + return Util::page($customer); } /**