public function main(Database $db, Request $request, HTML $html, $page = 1) { if (false === is_numeric($page)) { return $this->notFound(['message' => "Halaman '{$page}' tidak ditemukan!"]); } $filter = []; if ($keyword = $request->query('keyword')) { $filter = ['(name like :keyword or username like :keyword)', ':keyword' => '%' . $keyword . '%']; } $subset = $db->paginate('user', $filter, null, is_numeric($page) ? $page : 1); $pagination = $html->pagination($subset, ['route' => $this->homeUrl . '/{page}', 'params' => ['page' => $page]]); return $this->render('user/list', ['subset' => $subset, 'homeUrl' => $this->homeUrl, 'keyword' => $keyword, 'pagination' => $pagination, 'printUrl' => $this->homeUrl . '/preview', 'downloadUrl' => $this->homeUrl . '/download']); }
public function main(User $user, Database $db, Request $request, HTML $html, $page = 1) { if (false === is_numeric($page)) { return $this->notFound(['message' => "Halaman '{$page}' tidak ditemukan!"]); } $filter = ['id <> :self', ':self' => $user->get('id')]; if ($keyword = $request->query('keyword')) { $filter[0] .= ' and (name like :keyword or username like :keyword)'; $filter[':keyword'] = '%' . $keyword . '%'; } $subset = $db->paginate('user', $filter, null, is_numeric($page) ? $page : 1); $pagination = $html->pagination($subset, ['route' => $this->homeUrl . '/{page}', 'params' => ['page' => $page]]); return $this->render('user/list', ['subset' => $subset, 'homeUrl' => $this->homeUrl, 'keyword' => $keyword, 'pagination' => $pagination, 'createUrl' => $this->homeUrl . '/create', 'updateUrl' => $this->homeUrl . '/update/{id}', 'deleteUrl' => $this->homeUrl . '/delete/{id}', 'detailUrl' => $this->homeUrl . '/detail/{id}']); }