get(CategoryModel::TYPE_HELP); $helpRepo = new HelpRepo(); $helps = $helpRepo->findAll([ 'published' => 1, 'deleted' => 0, ]); $result = []; foreach ($categories as $category) { $item = []; $item['category'] = [ 'id' => $category['id'], 'name' => $category['name'], ]; $item['helps'] = []; if ($helps->count() > 0) { foreach ($helps as $help) { $item['helps'][] = [ 'id' => $help->id, 'title' => $help->title, ]; } } $result[] = $item; } return $result; } }