public function getBySlug($slug) { $book = $this->bookQuery()->where('slug', '=', $slug)->first(); if ($book === null) { throw new NotFoundException('Book not found'); } return $book; }