X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/cd7788f2e9e8187c290dacbacbb38608d9a50a56..refs/pull/3918/head:/app/Entities/Models/Chapter.php diff --git a/app/Entities/Models/Chapter.php b/app/Entities/Models/Chapter.php index 08d6608a9..98889ce3f 100644 --- a/app/Entities/Models/Chapter.php +++ b/app/Entities/Models/Chapter.php @@ -18,8 +18,8 @@ class Chapter extends BookChild public $searchFactor = 1.2; - protected $fillable = ['name', 'description', 'priority', 'book_id']; - protected $hidden = ['restricted', 'pivot', 'deleted_at']; + protected $fillable = ['name', 'description', 'priority']; + protected $hidden = ['pivot', 'deleted_at']; /** * Get the pages that this chapter contains. @@ -58,4 +58,13 @@ class Chapter extends BookChild ->orderBy('priority', 'asc') ->get(); } + + /** + * Get a visible chapter by its book and page slugs. + * @throws \Illuminate\Database\Eloquent\ModelNotFoundException + */ + public static function getBySlugs(string $bookSlug, string $chapterSlug): self + { + return static::visible()->whereSlugs($bookSlug, $chapterSlug)->firstOrFail(); + } }