public function updateBooks(int $authorId) { $author = Author::with('authorBooks.book')->find($authorId); // Get the books by the name, restrict to the single one and future books $books = $this->authorSearchService->find($author->name, true)->first(); foreach ($books as $book) { foreach ($author->authorBooks as $authorBook) { if ($books->contains('google_books_id', $book['google_books_id'])) { debug('Existing'); // Update } else { debug('Creating'); // Create $this->createMissingBooks($author, $books, $author->books()); } } } }
protected function getAuthors($name) { start_measure('authorSearch', 'Author Search'); $authors = $this->authorSearchService->find($name); stop_measure('authorSearch'); return $authors; }