示例#1
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);
     }
     $posts = $posts->findManyByCategory($category);
     return view('anomaly.module.posts::categories/index', compact('category', 'posts'));
 }
示例#3
0
 /**
  * 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;
 }
 /**
  * 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'));
 }