Пример #1
0
 /**
  * Mostra la raccolta degli articoli. Se viene specificata una categoria, vengono mostrati solo gli articoli
  * della categoria specificata.
  *
  * @param ArticleRepository $articleRepository
  * @param CategoryRepository $categoryRepository
  * @param Request $request
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  * @throws NotFoundException
  */
 public function getArticles(ArticleRepository $articleRepository, CategoryRepository $categoryRepository, Request $request)
 {
     $categories = $categoryRepository->getAll();
     if ($request->has('categoria')) {
         $category = $categoryRepository->findBySlug($request->get('categoria'));
         $articles = $articleRepository->getByCategory($category, $request->get('page', 1), true, true);
     } else {
         $articles = $articleRepository->getAll($request->get('page', 1), true, true);
     }
     return view('front.articles', compact('articles', 'categories'));
 }
 public function testCanGetAll()
 {
     $this->assertEmpty($this->repository->getAll());
     $this->saveTestCategory();
     $this->assertCount(1, $this->repository->getAll());
 }
Пример #3
0
 /**
  * Mostra l'elenco delle categorie presenti sul sito.
  *
  * @param CategoryRepository $categoryRepository
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function getIndex(CategoryRepository $categoryRepository)
 {
     $categories = $categoryRepository->getAll();
     return view('admin.category_index', compact('categories'));
 }