/**
  * Return an index of category posts.
  *
  * @param CategoryRepositoryInterface $categories
  * @param PostRepositoryInterface     $posts
  * @param                             $category
  * @return \Illuminate\View\View
  */
 public function index(CategoryRepositoryInterface $categories, PostRepositoryInterface $posts, $category)
 {
     if (!($category = $categories->findBySlug($category))) {
         abort(404);
     }
     $posts = $posts->findManyByCategory($category);
     return view('anomaly.module.posts::categories/index', compact('category', 'posts'));
 }
 /**
  * Return an RSS feed of recent posts by category.
  *
  * @param PostRepositoryInterface     $posts
  * @param CategoryRepositoryInterface $categories
  * @param ResponseFactory             $response
  * @param                             $category
  * @return \Illuminate\Http\Response|ResponseFactory
  */
 public function category(PostRepositoryInterface $posts, CategoryRepositoryInterface $categories, ResponseFactory $response, $category)
 {
     if (!($category = $categories->findBySlug($category))) {
         abort(404);
     }
     $response = $response->view('module::posts/rss', ['posts' => $posts->findManyByCategory($category)])->setTtl(3600);
     $response->headers->set('content-type', 'text/xml');
     return $response;
 }
Example #3
0
 /**
  * Run the seeder.
  */
 public function run()
 {
     $this->posts->truncate();
     $repository = new EntryRepository();
     $repository->setModel(new PostsDefaultPostsEntryModel());
     $repository->truncate();
     $type = $this->types->findBySlug('default');
     $category = $this->categories->findBySlug('news');
     $welcome = (new PostsDefaultPostsEntryModel())->create(['content' => '<p>Welcome to PyroCMS!</p>']);
     $this->posts->create(['en' => ['title' => 'Welcome to PyroCMS!', 'summary' => 'This is an example post to demonstrate the posts module.'], 'slug' => 'welcome-to-pyrocms', 'publish_at' => time(), 'enabled' => true, 'type' => $type, 'entry' => $welcome, 'category' => $category, 'author' => 1]);
 }
 /**
  * Return an index of category posts.
  *
  * @param CategoryRepositoryInterface $categories
  * @param PostRepositoryInterface     $posts
  * @param                             $category
  * @return \Illuminate\View\View
  */
 public function index(CategoryRepositoryInterface $categories, PostRepositoryInterface $posts, $category)
 {
     if (!($category = $categories->findBySlug($category))) {
         abort(404);
     }
     $this->dispatch(new AddPostsBreadcrumb());
     $this->dispatch(new AddCategoryBreadcrumb($category));
     $this->dispatch(new AddCategoryMetaTitle($category));
     $posts = $posts->findManyByCategory($category);
     return view('anomaly.module.posts::categories/index', compact('category', 'posts'));
 }
 /**
  * Redirect to a category's URL.
  *
  * @param CategoryRepositoryInterface $categories
  * @param                             $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function view(CategoryRepositoryInterface $categories, $id)
 {
     /* @var CategoryInterface $category */
     $category = $categories->find($id);
     return $this->redirect->to($category->path());
 }
 /**
  * Delete a category.
  *
  * @param CategoryRepositoryInterface $categories
  * @param Authorizer                  $authorizer
  * @param                             $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function delete(CategoryRepositoryInterface $categories, Authorizer $authorizer, $id)
 {
     $authorizer->authorize('anomaly.module.posts::categories.delete');
     $categories->delete($categories->find($id));
     return redirect()->back();
 }
 /**
  * Run the seeder.
  */
 public function run()
 {
     $this->categories->truncate();
     $this->categories->create(['en' => ['name' => 'News', 'description' => 'Company news and updates.'], 'slug' => 'news']);
 }