X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/ac80723058ab4c86e6bf024e0c75b60ab6c59624..refs/pull/263/head:/app/Page.php diff --git a/app/Page.php b/app/Page.php index 94bcce2b5..b24e7778a 100644 --- a/app/Page.php +++ b/app/Page.php @@ -7,6 +7,10 @@ class Page extends Entity protected $simpleAttributes = ['name', 'id', 'slug']; + protected $with = ['book']; + + protected $fieldsToSearch = ['name', 'text']; + /** * Converts this page into a simplified array. * @return mixed @@ -55,12 +59,12 @@ class Page extends Entity } /** - * Get the files attached to this page. + * Get the attachments assigned to this page. * @return \Illuminate\Database\Eloquent\Relations\HasMany */ - public function files() + public function attachments() { - return $this->hasMany(File::class, 'uploaded_to')->orderBy('order', 'asc'); + return $this->hasMany(Attachment::class, 'uploaded_to')->orderBy('order', 'asc'); } /** @@ -72,13 +76,13 @@ class Page extends Entity { $bookSlug = $this->getAttribute('bookSlug') ? $this->getAttribute('bookSlug') : $this->book->slug; $midText = $this->draft ? '/draft/' : '/page/'; - $idComponent = $this->draft ? $this->id : $this->slug; + $idComponent = $this->draft ? $this->id : urlencode($this->slug); if ($path !== false) { - return baseUrl('/books/' . $bookSlug . $midText . $idComponent . '/' . trim($path, '/')); + return baseUrl('/books/' . urlencode($bookSlug) . $midText . $idComponent . '/' . trim($path, '/')); } - return baseUrl('/books/' . $bookSlug . $midText . $idComponent); + return baseUrl('/books/' . urlencode($bookSlug) . $midText . $idComponent); } /**