You could write something like this I think:
$books = Book::whereIn('id', $ids)->get();
$books
will be a Collection
containing all your books.
Pregunta
I got a list of IDs and need to get a Collection (Let's say of the type "Book") and add Single Books to this Collection by Hand.
Example:
$ids = array(1,5,7,12);
$books = ???
foreach($ids as $id){
$books->add(Book::find($id)); }
Or is there a easier way to get what I want?
Thank you
Solución
You could write something like this I think:
$books = Book::whereIn('id', $ids)->get();
$books
will be a Collection
containing all your books.