public function render() { $params = $this->params; $route = isset($params['route']) ? $params['route'] : \null; unset($params['route']); foreach ($params as $k => $v) { if (substr($v, 0, 1) === ':') { $field = substr($v, 1); $params[$k] = $this->getCurrentValue($field); } } $value = parent::render(); return '<a' . ($this->hrefClass ? ' class="' . $this->hrefClass . '"' : '') . ' href="' . $this->router->assemble($route, $params, $this->reset, $this->qsa) . '">' . $value . '</a>'; }
public function render() { $paginator = $this->grid->getPaginator(); $buttons = $this->grid->getButtons(); $output = ''; $buttonsCode = ''; $request = app('request'); $requestParams = $request->getParams(); $requestParams = array_diff_key($requestParams, $request->getPost()); foreach ($requestParams as $key => $requestParam) { if (!is_array($requestParam)) { continue; } unset($requestParams[$key]); } if (!empty($buttons)) { $output .= '<form class="grid-form" method="post" action="' . $this->router->assemble(\null) . '">'; $buttonsCode = '<div class="grid-buttons">'; foreach ($buttons as $name => $button) { try { $button = new Element\Submit($name, $button); $buttonsCode .= $button->render() . ' '; } catch (\Exception $e) { if (env('development')) { $buttonsCode .= $e->getMessage(); } } } $buttonsCode .= '</div>'; if ($this->grid->getButtonsPlacement() & Grid::PLACEMENT_TOP) { $output .= $buttonsCode; } } $renderPagination = ''; if ($this->grid->getPaginatorPlacement() & Grid::PLACEMENT_TOP || $this->grid->getPaginatorPlacement() & Grid::PLACEMENT_BOTTOM) { $renderPagination = $this->renderPagination(); } if ($this->grid->getPaginatorPlacement() & Grid::PLACEMENT_TOP) { $output .= $renderPagination; } $output .= '<div class="table-responsive">'; $output .= '<table class="table table-bordered table-hover' . ($this->grid->getGridClass() ? ' ' . $this->grid->getGridClass() : '') . '">'; $output .= '<thead>'; $output .= '<tr class="table-row-head">'; foreach ($this->grid->getColumns() as $column) { if (!$column instanceof Column) { continue; } if ($column->isSortable()) { $sortedClass = 'sorting'; if ($column->isSorted()) { $sortedClass = 'sorting_' . $column->getSorted(); } $routeParams = array_merge($requestParams, ['orderField' => $column->getName(), 'orderDir' => $column->getSorted() == 'asc' ? 'desc' : 'asc']); $title = '<div class="' . $sortedClass . '" data-url="' . $this->router->assemble(\null, $routeParams) . '">' . $column->getTitle() . '</div>'; } else { $title = $column->getTitle(); } $output .= '<th' . ($column->getHeadStyle() ? ' style="' . $column->getHeadStyle() . '"' : '') . ' class="table-cell-head' . ($column->getHeadClass() ? ' ' . $column->getHeadClass() : '') . '">'; $output .= $title; $output .= '</th>'; } $output .= '</tr>'; $output .= '</thead>'; $output .= '<tbody>'; foreach ($paginator as $key => $page) { $output .= '<tr class="table-row">'; foreach ($this->grid->getColumns() as $column) { if (!$column instanceof Column) { continue; } $output .= '<td' . ($column->getStyle() ? ' style="' . $column->getStyle() . '"' : '') . ' class="table-cell' . ($column->getClass() ? ' ' . $column->getClass() : '') . '">'; try { $output .= $column->render(); } catch (\Exception $e) { if (env('development')) { $output .= $e->getMessage(); } else { $output .= ' '; } } $output .= '</td>'; } $output .= '</tr>'; } $output .= '</tbody>'; $output .= '</table>'; $output .= '</div>'; if ($this->grid->getPaginatorPlacement() & Grid::PLACEMENT_BOTTOM) { $output .= $renderPagination; } if (!empty($buttons)) { if ($this->grid->getButtonsPlacement() & Grid::PLACEMENT_BOTTOM) { $output .= $buttonsCode; } $output .= '</form>'; } return $output; }