Exemplo n.º 1
0
 public function getCategories(&$data = [], $parent = NULL)
 {
     $category = Category::find()->where(['parent_id' => $parent, 'type' => 'forum'])->all();
     foreach ($category as $key => $value) {
         $data[] = ['id' => $value->id, 'slug' => $value->slug, 'title' => $this->getIndent($value->indent) . $value->title];
         unset($category[$key]);
         $this->getCategories($data, $value->id);
     }
     return $data;
 }
Exemplo n.º 2
0
 public function getCategories($type = NULL, &$data = [], $parent = NULL)
 {
     $category = Category::find()->where(['parent_id' => $parent, 'type' => $type])->andWhere(['NOT IN', 'id', !$this->isNewRecord ? $this->id : 0])->all();
     foreach ($category as $key => $value) {
         $data[$value->id] = $this->getIndent($value->indent) . $value->title;
         unset($category[$key]);
         $this->getCategories($type, $data, $value->id);
     }
     return $data;
 }
Exemplo n.º 3
0
 public function getCategories($type, &$data = [], $parent = NULL)
 {
     $post = Post::findOne($this->id);
     $category = Category::find()->where(['parent_id' => $parent, 'type' => $type])->all();
     foreach ($category as $key => $value) {
         if (!empty($post->category_id) && in_array($value->id, explode(',', $post->category_id))) {
             $checked = 1;
         } else {
             $checked = 0;
         }
         $data[] = ['id' => $value->id, 'title' => $this->getIndent($value->indent) . $value->title, 'checked' => $checked];
         unset($category[$key]);
         $this->getCategories($type, $data, $value->id);
     }
     return $data;
 }
Exemplo n.º 4
0
 protected function categories(&$data = [], $parent = NULL)
 {
     $category = Category::find()->where(['parent_id' => $parent, 'type' => 'forum'])->all();
     foreach ($category as $key => $value) {
         $data[] = $value;
         unset($category[$key]);
         $this->categories($data, $value->id);
     }
     return $data;
 }