Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dist/js/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,8 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
model: this.field.model ? this.field.model : "",
id: this.field.id ? this.field.id : "",
resource: this.field.resource ? this.field.resource : "",
relations: this.field.relations ? this.field.relations : ""
relations: this.field.relations ? this.field.relations : "",
mediaCollection: this.field.mediaCollection ? this.field.mediaCollection : "",
}).then(function (response) {
window.location.replace(response.data.destination);
}).catch(function (error) {
Expand Down Expand Up @@ -2110,4 +2111,4 @@ if (false) {
}

/***/ })
/******/ ]);
/******/ ]);
3 changes: 2 additions & 1 deletion resources/js/components/IndexField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export default {
model: this.field.model ? this.field.model : "",
id: this.field.id ? this.field.id : "",
resource: this.field.resource ? this.field.resource : "",
relations: this.field.relations ? this.field.relations : ""
relations: this.field.relations ? this.field.relations : "",
mediaCollection: this.field.mediaCollection ? this.field.mediaCollection : ""
})
.then(response => {
window.location.replace(response.data.destination);
Expand Down
9 changes: 9 additions & 0 deletions src/Http/Controllers/DuplicateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ public function duplicate(Request $request)

$newModel = $model->replicate();
$newModel->push();

// Duplicate spatie media if we are using the package
if(method_exists($model, 'getMedia') && method_exists($model, 'copyMedia') && $request->mediaCollection) {
$images = $model->getMedia($request->mediaCollection);

foreach ($images as $image) {
$newModel->copyMedia($image->getPath())->toMediaCollection($request->mediaCollection);
}
}

if (isset($request->relations) && !empty($request->relations)) {
// load the relations
Expand Down