/** * Search posts from category * * @param $slug * @param int $perPage * @return array */ public function search($slug, $perPage = 5) { $category = $this->findBySlug($slug); $data = []; return ['category' => $category, 'posts' => $this->category->search($category['id'], $data, $perPage)]; }