1 <?php namespace Oxbow\Repos;
4 use Illuminate\Support\Str;
12 * PageRepo constructor.
15 public function __construct(Page $page)
20 public function getById($id)
22 return $this->page->findOrFail($id);
25 public function getAll()
27 return $this->page->all();
30 public function getBySlug($slug, $bookId)
32 return $this->page->where('slug', '=', $slug)->where('book_id', '=', $bookId)->first();
35 public function newFromInput($input)
37 $page = $this->page->fill($input);
41 public function countBySlug($slug, $bookId)
43 return $this->page->where('slug', '=', $slug)->where('book_id', '=', $bookId)->count();
46 public function destroyById($id)
48 $page = $this->getById($id);
52 public function getBySearch($term)
54 $terms = explode(' ', trim($term));
56 foreach($terms as $term) {
57 $query = $query->where('text', 'like', '%'.$term.'%');