X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/afe1a042396454e071b4b3bb5bb0043586ba333a..refs/pull/3918/head:/app/Entities/Models/Page.php diff --git a/app/Entities/Models/Page.php b/app/Entities/Models/Page.php index 93729d7f2..a224071cc 100644 --- a/app/Entities/Models/Page.php +++ b/app/Entities/Models/Page.php @@ -39,7 +39,7 @@ class Page extends BookChild public $textField = 'text'; - protected $hidden = ['html', 'markdown', 'text', 'restricted', 'pivot', 'deleted_at']; + protected $hidden = ['html', 'markdown', 'text', 'pivot', 'deleted_at']; protected $casts = [ 'draft' => 'boolean', @@ -88,8 +88,6 @@ class Page extends BookChild /** * Get the current revision for the page if existing. - * - * @return PageRevision|null */ public function currentRevision(): HasOne { @@ -145,4 +143,13 @@ class Page extends BookChild return $refreshed; } + + /** + * Get a visible page by its book and page slugs. + * @throws \Illuminate\Database\Eloquent\ModelNotFoundException + */ + public static function getBySlugs(string $bookSlug, string $pageSlug): self + { + return static::visible()->whereSlugs($bookSlug, $pageSlug)->firstOrFail(); + } }