Skip to content

Commit

Permalink
Do the same for terms
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Nov 20, 2023
1 parent d69ed35 commit 0b20a5f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
3 changes: 3 additions & 0 deletions resources/js/components/terms/PublishForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@ export default {
this.$axios[this.method](this.actions.save, payload).then(response => {
this.saving = false;
if (! response.data.saved) {
return this.$toast.error(__(`Couldn't save term`));
}
this.title = response.data.data.title;
this.permalink = response.data.data.permalink;
this.isWorkingCopy = true;
Expand Down
22 changes: 6 additions & 16 deletions src/Http/Controllers/CP/Taxonomies/TermsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,11 @@ public function update(Request $request, $taxonomy, $term, $site)
$term->published($request->published);
}

$save = $term->updateLastModified(User::current())->save();

if (! $save) {
return response([
'message' => __("Couldn't save term"),
], 401);
}
$saved = $term->updateLastModified(User::current())->save();
}

return new TermResource($term);
return (new TermResource($term))
->additional(['saved' => $saved]);
}

public function create(Request $request, $taxonomy, $site)
Expand Down Expand Up @@ -305,16 +300,11 @@ public function store(Request $request, $taxonomy, $site)
'user' => User::current(),
]);
} else {
$save = $term->updateLastModified(User::current())->save();

if (! $save) {
return response([
'message' => __("Couldn't save term"),
], 401);
}
$saved = $term->updateLastModified(User::current())->save();
}

return new TermResource($term);
return (new TermResource($term))
->additional(['saved' => $saved]);
}

protected function extractFromFields($term, $blueprint)
Expand Down

0 comments on commit 0b20a5f

Please sign in to comment.