slug = Str::slug($term); $this->path = sprintf('/termes/%s', $this->slug); $this->bundle = new Bundle($this->path, $source->getDisk()); //$this->link = new Link($this->path, $term, $source); $this->bundle->load(); $currentRelations = $this->bundle->metadata('relations')->get($subCategory, []); if (!in_array($source->getPath(), $currentRelations)) { $currentRelations[] = $source->getPath(); $this->bundle->metadata('relations')->set($subCategory, collect($currentRelations)->unique()->toArray()); } if (empty($this->bundle->markdown()->get())) { $this->bundle->markdown()->set(''); } if (empty($this->bundle->metadata()->get('title'))) { $this->bundle->metadata()->set('title', $term); } $this->bundle->save(); } public function render() { return sprintf('%s', $this->path, $this->term); } public static function register(string $term, string $subCategory, Bundle $source) { return new static($term, $subCategory, $source); } }