public function get($userId) { $query = Book::query(); // TODO Include filtering the results by a list of books the user is not interested in from that author $books = $query->select('books.*')->joinUsersBooks($userId)->notYetPublished()->upcomingPublicationsFirst()->groupBy('user_authors.id')->get(); $books->load('authors.author'); return $books; }
protected function addBook(array $book, string $googleBookId) { return Book::create(['title' => $book['title'], 'subtitle' => $book['subtitle'], 'description' => $book['description'], 'publisher' => $book['publisher'], 'published_date' => $book['publishedDate'], 'google_books_id' => $googleBookId]); }