exists($collectionName)) { Storage::disk('public')->makeDirectory($collectionName); } $targetFile = Storage::disk('public')->path("{$collectionName}/{$file}"); File::copy(storage_path("tmp/uploads/{$file}"), $targetFile); $this->documents()->create([ 'title' => $documentName, 'file_path' => $file, 'collection_name' => $collectionName, ]); } public function documents(): MorphMany { return $this->morphMany(Document::class, 'documentable')->orderBy('order'); } }