BookStack\Repos\ChapterRepo::destroy PHP Method

destroy() public method

Destroy a chapter and its relations by providing its slug.
public destroy ( Chapter $chapter )
$chapter BookStack\Chapter
    public function destroy(Chapter $chapter)
    {
        if (count($chapter->pages) > 0) {
            foreach ($chapter->pages as $page) {
                $page->chapter_id = 0;
                $page->save();
            }
        }
        Activity::removeEntity($chapter);
        $chapter->views()->delete();
        $chapter->permissions()->delete();
        $this->permissionService->deleteJointPermissionsForEntity($chapter);
        $chapter->delete();
    }