I am inserting the data to the rows one by one, but I have heard somewhere that it requires much time if there are many data to insert. So what are the ways of inserting them all at once?
public function add(Request $request)
{
if ($request->ajax()) {
$books = $request->books;
foreach ($books as $book) {
if (!empty($book)) {
$add = new Book;
$add->name = $book;
$add->user_id = Auth::user()->id;
$add->save();
}
}
}
}