Since you're retrieving multiple Authors, Laravel returns it as a Collection. You cannot query on a collection, which means you have to run through it with a foreach for example.
By iterating through the collection
$allBooks = array();
foreach ($authors as $author){
$authorBooks = $author->books->get()->toArray();
$allBooks = array_merge($allBooks, $authorBooks);
}
I do recommend using scopes though.
An other solution might be working with scopes:
Create an array with your author id's. You can use ->lists('id') for this when using an object. (In this example, I take all authors, but you can restrict with ->where or a scope.)
$authorids= Author::all()->lists('id');
Create a scopeAuthorIds in your Book model, something like this:
public function scopeAuthorIds($query, $ids)
{
return $query->whereIn('authorId', $ids);
}
You should be able to filter your books on the author id's now, by doing
$allBooks = Book::AuthorIds($authorids)->get();