예제 #1
0
 public function find($id)
 {
     $model = Category::getInstance()->getOne($id);
     $model = $this->format($model);
     $model = $this->formatNumber($model);
     return $model;
 }
예제 #2
0
 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;
 }
예제 #3
0
 /**
  * 文章列表页面
  * @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);
 }
예제 #4
0
 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);
 }
예제 #5
0
 public function getNavList()
 {
     return Category::getInstance()->whereRaw('`pid`=0 AND `order` <> 0')->orderBy('order', 'ASC')->get();
 }