/** * Displays list of items. * * @param string $model Model to use. * @return \Illuminate\Http\Response */ public function index($model) { $this->setModel($model); $indexUrl = $this->getRoute('index'); $title = trans('lavanda::common.list_title', ['entity' => $this->staticModelGetPluralName()]); $columns = $this->staticModelGetListDescriptor(); $sortDescriptor = $this->staticModelGetSortDescriptor(); $searchForm = $this->staticModelGetSearchForm($indexUrl); $items = $this->staticModelGetList($this->request->get('query'), getUnencryptedCookie('sort'))->setPath($indexUrl); return view('lavanda::entity.index', ['title' => $title, 'columns' => $columns, 'getRoute' => $this->getRoute(), 'searchForm' => $searchForm, 'sortDescriptor' => $sortDescriptor, 'items' => $items, 'createAllowed' => $this->isActionAllowed('create'), 'editAllowed' => $this->isActionAllowed('edit'), 'destroyAllowed' => $this->isActionAllowed('destroy')]); }
/** * Renders sort select. * * @return string */ public function renderSortSelect() { if ($this->items) { $items = []; foreach ($this->items as $key => $item) { $items[$key . '#asc'] = $this->translator->trans('lavanda::common.sort_asc', ['item' => mb_strtolower($item)]); $items[$key . '#desc'] = $this->translator->trans('lavanda::common.sort_desc', ['item' => mb_strtolower($item)]); } $value = getUnencryptedCookie('sort'); return Form::select('sort', $items, $value ?: 'id#desc', ['class' => 'form-control', 'id' => 'sort']); } }