'staff_1', 'requestData' => [ 'page' => [ 'validation' => DataValidator::numeric(), 'error' => ERRORS::INVALID_PAGE ], 'pageSize' => [ 'validation' => DataValidator::oneOf(DataValidator::intVal()->between(5, 50),DataValidator::nullType()), 'error' => ERRORS::INVALID_PAGE_SIZE ] ] ]; } public function handler() { $user = Controller::getLoggedUser(); $closed = Controller::request('closed'); $page = Controller::request('page'); $departmentId = Controller::request('departmentId'); $pageSize = Controller::request('pageSize') ? Controller::request('pageSize') : 10; $offset = ($page-1)*$pageSize; $condition = 'TRUE'; $bindings = []; if($departmentId) { $condition .= ' AND department_id = ?'; $bindings[] = $departmentId; } if(!$closed) { $condition .= ' AND closed = ?'; $bindings[] = '0'; } $countTotal = $user->withCondition($condition, $bindings)->countShared('ticket'); $condition .= ' LIMIT ' . $pageSize . ' OFFSET ?'; $bindings[] = $offset; $tickets = $user->withCondition($condition, $bindings)->sharedTicketList->toArray(true); Response::respondSuccess([ 'tickets' => $tickets, 'page' => $page, 'pages' => ceil($countTotal / $pageSize) ]); } }