- $stringExploded = explode(':', $entitySelection);
- $entityType = $stringExploded[0];
- $entityId = intval($stringExploded[1]);
-
- $parent = false;
-
- if ($entityType == 'book') {
- $parent = $this->entityRepo->getById('book', $entityId);
- }
-
- if ($parent === false || $parent === null) {
- session()->flash('error', trans('errors.selected_book_not_found'));
+ try {
+ $newBook = $this->chapterRepo->move($chapter, $entitySelection);
+ } catch (MoveOperationException $exception) {
+ $this->showErrorNotification(trans('errors.selected_book_not_found'));