BookStack\Chapter::pages PHP Method

pages() public method

Get the pages that this chapter contains.
public pages ( ) : mixed
return mixed
    public function pages()
    {
        return $this->hasMany(Page::class)->orderBy('priority', 'ASC');
    }

Usage Example

Example #1
0
 /**
  * Get the child items for a chapter
  * @param Chapter $chapter
  */
 public function getChildren(Chapter $chapter)
 {
     $pages = $this->permissionService->enforcePageRestrictions($chapter->pages())->get();
     // Sort items with drafts first then by priority.
     return $pages->sortBy(function ($child, $key) {
         $score = $child->priority;
         if ($child->draft) {
             $score -= 100;
         }
         return $score;
     });
 }