namespace BookStack\Entities\Models;
+use BookStack\References\ReferenceUpdater;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
*/
public function changeBook(int $newBookId): Entity
{
+ $oldUrl = $this->getUrl();
$this->book_id = $newBookId;
$this->refreshSlug();
$this->save();
$this->refresh();
+ if ($oldUrl !== $this->getUrl()) {
+ app()->make(ReferenceUpdater::class)->updateEntityPageReferences($this, $oldUrl);
+ }
+
// Update all child pages if a chapter
if ($this instanceof Chapter) {
foreach ($this->pages()->withTrashed()->get() as $page) {