return $page;
}
+ /**
+ * Count the pages with a particular slug within a book.
+ * @param $slug
+ * @param $bookId
+ * @return mixed
+ */
+ public function countBySlug($slug, $bookId)
+ {
+ return $this->page->where('slug', '=', $slug)->where('book_id', '=', $bookId)->count();
+ }
/**
* Save a new page into the system.
*/
public function getBySearch($term, $whereTerms = [], $count = 20, $paginationAppends = [])
{
- $terms = explode(' ', $term);
+ preg_match_all('/"(.*?)"/', $term, $matches);
+ if (count($matches[1]) > 0) {
+ $terms = $matches[1];
+ $term = trim(preg_replace('/"(.*?)"/', '', $term));
+ } else {
+ $terms = [];
+ }
+ if (!empty($term)) {
+ $terms = array_merge($terms, explode(' ', $term));
+ }
$pages = $this->restrictionService->enforcePageRestrictions($this->page->fullTextSearchQuery(['name', 'text'], $terms, $whereTerms))
->paginate($count)->appends($paginationAppends);