belongsToMany(Goods::class, 'goods_category')->withTimestamps(); } public function getCoverPathAttribute() { if ($this->cover) { return env('APP_URL') . '/storage/' . $this->cover; } else { return '/assets/index/img/product_active.png'; } } public function children() { return $this->hasMany(Category::class, 'parent_id', 'id'); } }