*/
private function bookQuery()
{
- return $this->restrictionService->enforceBookRestrictions($this->book, 'view');
+ return $this->permissionService->enforceBookRestrictions($this->book, 'view');
}
/**
$book->created_by = auth()->user()->id;
$book->updated_by = auth()->user()->id;
$book->save();
- $this->restrictionService->buildEntityPermissionsForEntity($book);
+ $this->permissionService->buildJointPermissionsForEntity($book);
return $book;
}
$book->slug = $this->findSuitableSlug($book->name, $book->id);
$book->updated_by = auth()->user()->id;
$book->save();
- $this->restrictionService->buildEntityPermissionsForEntity($book);
+ $this->permissionService->buildJointPermissionsForEntity($book);
return $book;
}
$this->chapterRepo->destroy($chapter);
}
$book->views()->delete();
- $book->restrictions()->delete();
- $this->restrictionService->deleteEntityPermissionsForEntity($book);
+ $book->permissions()->delete();
+ $this->permissionService->deleteJointPermissionsForEntity($book);
$book->delete();
}
/**
- * Alias method to update the book permissions in the RestrictionService.
+ * Alias method to update the book jointPermissions in the PermissionService.
* @param Book $book
*/
public function updateBookPermissions(Book $book)
{
- $this->restrictionService->buildEntityPermissionsForEntity($book);
+ $this->permissionService->buildJointPermissionsForEntity($book);
}
/**
public function getChildren(Book $book, $filterDrafts = false)
{
$pageQuery = $book->pages()->where('chapter_id', '=', 0);
- $pageQuery = $this->restrictionService->enforcePageRestrictions($pageQuery, 'view');
+ $pageQuery = $this->permissionService->enforcePageRestrictions($pageQuery, 'view');
if ($filterDrafts) {
$pageQuery = $pageQuery->where('draft', '=', false);
$pages = $pageQuery->get();
$chapterQuery = $book->chapters()->with(['pages' => function($query) use ($filterDrafts) {
- $this->restrictionService->enforcePageRestrictions($query, 'view');
+ $this->permissionService->enforcePageRestrictions($query, 'view');
if ($filterDrafts) $query->where('draft', '=', false);
}]);
- $chapterQuery = $this->restrictionService->enforceChapterRestrictions($chapterQuery, 'view');
+ $chapterQuery = $this->permissionService->enforceChapterRestrictions($chapterQuery, 'view');
$chapters = $chapterQuery->get();
- $children = $pages->merge($chapters);
+ $children = $pages->values();
+ foreach ($chapters as $chapter) {
+ $children->push($chapter);
+ }
$bookSlug = $book->slug;
$children->each(function ($child) use ($bookSlug) {
public function getBySearch($term, $count = 20, $paginationAppends = [])
{
$terms = $this->prepareSearchTerms($term);
- $books = $this->restrictionService->enforceBookRestrictions($this->book->fullTextSearchQuery(['name', 'description'], $terms))
- ->paginate($count)->appends($paginationAppends);
+ $bookQuery = $this->permissionService->enforceBookRestrictions($this->book->fullTextSearchQuery(['name', 'description'], $terms));
+ $bookQuery = $this->addAdvancedSearchQueries($bookQuery, $term);
+ $books = $bookQuery->paginate($count)->appends($paginationAppends);
$words = join('|', explode(' ', preg_quote(trim($term), '/')));
foreach ($books as $book) {
//highlight