1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Rolled out reference link updating logic usage

Added test to cover updating of content on reference url change
This commit is contained in:
Dan Brown
2022-08-21 18:05:19 +01:00
parent 0dbf08453f
commit b86ee6d252
5 changed files with 101 additions and 15 deletions

View File

@ -2,6 +2,7 @@
namespace BookStack\Entities\Models;
use BookStack\References\ReferenceUpdater;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@ -57,9 +58,15 @@ abstract class BookChild extends Entity
*/
public function changeBook(int $newBookId): Entity
{
$oldUrl = $this->getUrl();
$this->book_id = $newBookId;
$this->refreshSlug();
$this->save();
if ($oldUrl !== $this->getUrl()) {
app()->make(ReferenceUpdater::class)->updateEntityPageReferences($this, $oldUrl);
}
$this->refresh();
// Update all child pages if a chapter