/**
* BookRepo constructor.
- * @param Book $book
+ * @param Book $book
* @param PageRepo $pageRepo
*/
public function __construct(Book $book, PageRepo $pageRepo)
return $this->book->all();
}
+ /**
+ * Getas
+ * @param int $count
+ * @return mixed
+ */
+ public function getAllPaginated($count = 10)
+ {
+ return $this->book->orderBy('name', 'asc')->paginate($count);
+ }
+
public function getBySlug($slug)
{
return $this->book->where('slug', '=', $slug)->first();
public function destroyBySlug($bookSlug)
{
$book = $this->getBySlug($bookSlug);
- foreach($book->pages as $page) {
+ foreach ($book->pages as $page) {
\Activity::removeEntity($page);
$page->delete();
}
- foreach($book->chapters as $chapter) {
+ foreach ($book->chapters as $chapter) {
\Activity::removeEntity($chapter);
$chapter->delete();
}
public function doesSlugExist($slug, $currentId = false)
{
$query = $this->book->where('slug', '=', $slug);
- if($currentId) {
+ if ($currentId) {
$query = $query->where('id', '!=', $currentId);
}
return $query->count() > 0;
$originalSlug = Str::slug($name);
$slug = $originalSlug;
$count = 2;
- while($this->doesSlugExist($slug, $currentId)) {
+ while ($this->doesSlugExist($slug, $currentId)) {
$slug = $originalSlug . '-' . $count;
$count++;
}
.left + .right {
margin-left: 30px + $-s;
}
+}
+
+ul.pagination {
+ display: inline-block;
+ list-style: none;
+ margin: $-m 0;
+ li {
+ float: left;
+ }
+ li:first-child {
+ a, span {
+ border-radius: 3px 0 0 3px;
+ }
+ }
+ li:last-child {
+ a, span {
+ border-radius: 0 3px 3px 0;
+ }
+ }
+ a, span {
+ display: block;
+ padding: $-xxs $-s;
+ border: 1px solid #CCC;
+ margin-left: -1px;
+ color: #888;
+ user-select: none;
+ &.disabled {
+ cursor: not-allowed;
+ }
+ }
+ li.active span {
+ background-color: rgba($primary, 0.8);
+ color: #EEE;
+ border-color: rgba($primary, 0.8);
+ }
+ a {
+ color: $primary;
+ }
}
\ No newline at end of file