PHP Class BookStack\Repos\BookRepo

Inheritance: extends EntityRepo
Show file Open project: ssddanbrown/bookstack

Protected Properties

Property Type Description
$chapterRepo
$pageRepo

Public Methods

Method Description
__construct ( PageRepo $pageRepo, ChapterRepo $chapterRepo ) BookRepo constructor.
createFromInput ( array $input ) : Book Get a new book instance from request input.
destroy ( Book $book ) Destroy the given book.
doesSlugExist ( string $slug, boolean | false $currentId = false ) : boolean
exists ( $id ) : boolean Checks if a book exists.
findSuitableSlug ( string $name, boolean | false $currentId = false ) : string Provides a suitable slug for the given book name.
getAll ( integer $count = 10 ) : mixed Get all books, Limited by count.
getAllPaginated ( integer $count = 10 ) : mixed Get all books paginated.
getById ( $id ) : mixed Get the book that has the given id.
getBySearch ( $term, integer $count = 20, array $paginationAppends = [] ) : mixed Get books by search term.
getBySlug ( $slug ) : mixed Get a book by slug
getChildren ( Book $book, boolean $filterDrafts = false ) : mixed Get all child objects of a book.
getLatest ( integer $count = 10 ) : mixed Get the latest books.
getNewPriority ( Book $book ) : integer Get the next child element priority.
getPopular ( integer $count = 10, integer $page ) : mixed Gets the most viewed books.
getRecentlyViewed ( integer $count = 10, integer $page ) : mixed Gets the most recently viewed for a user.
updateFromInput ( Book $book, $input ) : Book Update the given book from user input.

Private Methods

Method Description
bookQuery ( ) : mixed Base query for getting books.

Method Details

__construct() public method

BookRepo constructor.
public __construct ( PageRepo $pageRepo, ChapterRepo $chapterRepo )
$pageRepo PageRepo
$chapterRepo ChapterRepo

createFromInput() public method

Get a new book instance from request input.
public createFromInput ( array $input ) : Book
$input array
return BookStack\Book

destroy() public method

Destroy the given book.
public destroy ( Book $book )
$book BookStack\Book

doesSlugExist() public method

public doesSlugExist ( string $slug, boolean | false $currentId = false ) : boolean
$slug string
$currentId boolean | false
return boolean

exists() public method

Checks if a book exists.
public exists ( $id ) : boolean
$id
return boolean

findSuitableSlug() public method

Ensures the returned slug is unique in the system.
public findSuitableSlug ( string $name, boolean | false $currentId = false ) : string
$name string
$currentId boolean | false
return string

getAll() public method

Get all books, Limited by count.
public getAll ( integer $count = 10 ) : mixed
$count integer
return mixed

getAllPaginated() public method

Get all books paginated.
public getAllPaginated ( integer $count = 10 ) : mixed
$count integer
return mixed

getById() public method

Get the book that has the given id.
public getById ( $id ) : mixed
$id
return mixed

getBySearch() public method

Get books by search term.
public getBySearch ( $term, integer $count = 20, array $paginationAppends = [] ) : mixed
$term
$count integer
$paginationAppends array
return mixed

getBySlug() public method

Get a book by slug
public getBySlug ( $slug ) : mixed
$slug
return mixed

getChildren() public method

Returns a sorted collection of Pages and Chapters. Loads the book slug onto child elements to prevent access database access for getting the slug.
public getChildren ( Book $book, boolean $filterDrafts = false ) : mixed
$book BookStack\Book
$filterDrafts boolean
return mixed

getLatest() public method

Get the latest books.
public getLatest ( integer $count = 10 ) : mixed
$count integer
return mixed

getNewPriority() public method

Get the next child element priority.
public getNewPriority ( Book $book ) : integer
$book BookStack\Book
return integer

getPopular() public method

Gets the most viewed books.
public getPopular ( integer $count = 10, integer $page ) : mixed
$count integer
$page integer
return mixed

getRecentlyViewed() public method

Gets the most recently viewed for a user.
public getRecentlyViewed ( integer $count = 10, integer $page ) : mixed
$count integer
$page integer
return mixed

updateFromInput() public method

Update the given book from user input.
public updateFromInput ( Book $book, $input ) : Book
$book BookStack\Book
$input
return BookStack\Book

Property Details

$chapterRepo protected property

protected $chapterRepo

$pageRepo protected property

protected $pageRepo