/** * @return View */ public function table() { if ($result = $this->checkCustomActionCall()) { return $result; } if (Input::get('datatable_request')) { return $this->asyncTable(); } $this->queryState->save(); $columns = $this->modelItem->getColumns(); $unsortableColumns = []; $nameToSequanceNumber = []; foreach ($columns as $i => $column) { $nameToSequanceNumber[$column->getName()] = $i; if ($column->isSortable() == false) { $unsortableColumns[] = $i; } } $viewFilters = $this->modelItem->getViewFilters(); $jsFilters = []; foreach ($viewFilters as $i => $filter) { $filterData = ['type' => $filter->getFilterType(), 'sequanceNumber' => isset($nameToSequanceNumber[$filter->getName()]) ? $nameToSequanceNumber[$filter->getName()] : null]; if ($filter->getFilterType() == \SleepingOwl\Admin\ViewFilters\ViewFilter\Date::TYPE) { $filterData['rule'] = $filter->getRule(); } $jsFilters[] = $filterData; } $data = ['title' => $this->modelItem->getTitle(), 'columns' => $columns, 'viewFilters' => $viewFilters, 'newEntryRoute' => $this->admin_router->routeToCreate($this->modelName, Input::query()), 'modelItem' => $this->modelItem, 'unsortableColumns' => $unsortableColumns, 'jsFilters' => $jsFilters, 'rows' => []]; if (!$this->modelItem->isAsync()) { $tableData = []; try { $tableData = $this->modelRepository->tableData(); } catch (ModelNotFoundException $e) { return $this->pageNotFound(); } $data = array_merge($data, $tableData); } $data['subtitle'] = $this->modelRepository->getSubtitle(); return $this->makeView('model.table', $data); }
/** * @return View */ public function table() { if ($result = $this->checkCustomActionCall()) { return $result; } if (Input::get('datatable_request')) { return $this->asyncTable(); } $this->queryState->save(); $data = ['title' => $this->modelItem->getTitle(), 'columns' => $this->modelItem->getColumns(), 'newEntryRoute' => $this->admin_router->routeToCreate($this->modelName, Input::query()), 'modelItem' => $this->modelItem, 'rows' => []]; if (!$this->modelItem->isAsync()) { $tableData = []; try { $tableData = $this->modelRepository->tableData(); } catch (ModelNotFoundException $e) { App::abort(404); } $data = array_merge($data, $tableData); } $data['subtitle'] = $this->modelRepository->getSubtitle(); return $this->makeView('model.table', $data); }