$this->id, "name" => $this->name, "en_name" => $this->en_name, "thumb" => $this->thumb, "level" => $this->level, "parent_id" => optional($this->parent)->id ?? 0, "parent_name" => optional($this->parent)->name ?? 0, "weight" => $this->weight, "index_weight" => $this->index_weight, "category_weight" => $this->category_weight, "search_weight" => $this->search_weight, ]; return $return; } public function parent() { return $this->belongsTo(Category::class, "parent_id"); } public function childS() { return $this->hasMany(Category::class, "parent_id", "id"); } public function gcMap() { return $this->hasMany(GoodsCategoryMap::class, "category_id", "id"); } }