public function find($id) { $model = Category::getInstance()->getOne($id); $model = $this->format($model); $model = $this->formatNumber($model); return $model; }
public function getNavList() { $model = Category::getInstance()->whereRaw('`pid`=0 AND `order` <> 0')->orderBy('order', 'ASC')->get(); $results = []; foreach ($model as $item) { $item = $this->format($item); $item = $this->formatNumber($item); $results[] = $item; } return $results; }
/** * 文章列表页面 * @param $category * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View */ public function getList($category) { $category = Category::getInstance()->findByName($category); if (empty($category)) { return redirect('/site/index'); } $articles = Article::getInstance()->findByCategory($category->id); $this->viewData('crumbs', $this->articleCrumbs($category)); $this->viewData('summary', $this->articleSummary($category)); $this->viewData('articles', $this->articleList($articles)); $this->viewData('bodyId', 'article-container'); $this->viewData('navMenuActive', 'article-detail'); return view('frontend.article.category', $this->viewData); }
public function renderSideTree() { $str[] = '<ul>'; $data = Category::getInstance()->getNavList(); $tpl = '<li><a href="%s" title="%s">%s (%s)</a></li>'; foreach ($data as $item) { $str[] = sprintf($tpl, '/article/' . strtolower($item->name), $item->name, $item->name, $item->article_amount); } $str[] = '</ul>'; echo implode('', $str); }
public function getNavList() { return Category::getInstance()->whereRaw('`pid`=0 AND `order` <> 0')->orderBy('order', 'ASC')->get(); }