Пример #1
0
 public function index(Application $app, $page, Request $request)
 {
     $categories = new Categories();
     $list = $categories->getItems($app, $page);
     $categories->removeThisItem($app, $request);
     return $app['twig']->render('category.twig', array('page' => $request->get('page'), 'category' => $list));
 }
Пример #2
0
 public function getCategoryNavigate()
 {
     return Cache::store($this->store)->rememberForever('menu:cat', function () {
         $cat_cl = new Categories();
         $categories = $cat_cl->getAllCategory();
         foreach ($categories as $key => $category) {
             $date[$key]['id'] = $category->id;
             $date[$key]['name'] = $category->name;
             $date[$key]['curl'] = $category->curl;
             //Получаем кол-во новостей в каждой категории
             $date[$key]['count_article'] = $category->getArticlesByCondition()->count();
         }
         return $date;
     });
 }
Пример #3
0
 public function getAllByCat($id)
 {
     return Cache::store('prevCat')->rememberForever($id . ':' . $this->page, function () use($id) {
         $categories = new Categories();
         $category = $categories->getById($id)->first();
         //Для хлебных крошек
         $items['category'] = ['id' => $category->id, 'name' => $category->name, 'curl' => $category->curl];
         //методанные
         $items['title'] = $category->name;
         $items['keywords'] = 'блог, разработка, категория, ' . $category->name;
         if ($category->meta_keywords != '') {
             //Доп ключевые слова
             $items['keywords'] .= ',' . $category->meta_keywords;
         }
         $items['description'] = 'Блог начинающего backend разработчика' . 'Все статьи категории ' . $category->name . '.' . $category->meta_descriptiom;
         //Превьюхи
         $articles = $category->articles()->published()->orderByParam()->with('tags', 'category')->paginate($this->countPage);
         //Превьюхи в нужном формате
         $items['articles'] = $this->createArrPreviews($articles);
         return $this->createLengthAwarePaginator($articles, $items);
     });
 }