public function categoryPostsIndex($categoryId)
 {
     $category = PostCategory::findOrFail($categoryId);
     $otherCategories = PostCategory::where('id', '<>', $category->id)->get();
     $posts = $category->posts()->latest()->paginate(10);
     return view('admin.posts.index')->with(compact('category', 'posts', 'otherCategories'));
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $user = User::first();
     if (!$user) {
         $this->error('No user to import articles to');
         return;
     }
     $archives = PostCategory::where('name', 'archives')->first();
     if (!$archives) {
         $archives = PostCategory::create(['name' => 'archives', 'description' => 'old posts from prev site']);
     }
     $this->archiveId = $archives->id;
     $upperBound = intval($this->ask('What is the upper bound for the article ids?'));
     $articlesToFetch = collect(ImportResult::getMissingIdsUpToLimit($upperBound));
     $articlesToFetch->each(function ($id) use($user) {
         try {
             $reader = $this->articleReader->getPage($id);
             $this->import($reader, $id, $user);
             ImportResult::create(['article_id' => $id, 'imported' => 1]);
         } catch (\Exception $e) {
             $this->error('Failed on article ' . $id . ' : ' . $e->getMessage());
             ImportResult::create(['article_id' => $id, 'imported' => 0]);
         }
     });
 }