Exemple #1
0
 public function getCategories(&$data = [], $parent = NULL)
 {
     $category = Category::find()->where(['parent_id' => $parent, 'type' => 'post'])->all();
     foreach ($category as $key => $value) {
         $data[$value->id] = $this->getIndent($value->indent) . $value->title;
         unset($category[$key]);
         $this->getCategories($data, $value->id);
     }
     return $data;
 }
Exemple #2
0
 protected function categories(&$data = [], $parent = NULL)
 {
     $category = Category::find()->where(['parent_id' => $parent, 'type' => 'post'])->all();
     foreach ($category as $key => $value) {
         $data[] = $value;
         unset($category[$key]);
         $this->categories($data, $value->id);
     }
     return $data;
 }