Exemplo n.º 1
0
 /**
  * @return static
  */
 public function getRelationCategoryList()
 {
     $list = Collection::make();
     if ($this->model->hasParent()) {
         $data = $this->model->whereEnabled(true)->whereParentId($this->model->getAttribute('parent_id'))->orderBy('created_at', 'asc')->get();
     } else {
         $data = $this->model->whereEnabled(true)->whereParentId($this->model->getAttribute('id'))->orderBy('created_at', 'asc')->get();
     }
     if ($data->count()) {
         foreach ($data as $category) {
             $list->push(new Category($category->getAttribute('id')));
         }
     } else {
         $list->push(new Category($this->model->getAttribute('id')));
     }
     return $list;
 }