1 <?php namespace Oxbow\Repos;
12 * BookRepo constructor.
14 * @param PageRepo $pageRepo
16 public function __construct(Book $book, PageRepo $pageRepo)
19 $this->pageRepo = $pageRepo;
22 public function getById($id)
24 return $this->book->findOrFail($id);
27 public function getAll()
29 return $this->book->all();
32 public function getBySlug($slug)
34 return $this->book->where('slug', '=', $slug)->first();
37 public function newFromInput($input)
39 return $this->book->fill($input);
42 public function countBySlug($slug)
44 return $this->book->where('slug', '=', $slug)->count();
47 public function destroyBySlug($bookSlug)
49 $book = $this->getBySlug($bookSlug);
50 foreach($book->children() as $child) {
56 public function getNewPriority($book)
58 $lastElem = $book->children()->pop();
59 return $lastElem ? $lastElem->priority + 1 : 0;