Answer the question
In order to leave comments, you need to log in
How to reduce the number of queries in polymorphic one-to-many relationships?
Hello, please tell me, I have the following method:
public static function contentSetImages(Category $category, $paths)
{
$images = [];
foreach ($paths as $path) {
$images[] = Image::create(['src' => $path]);
}
$category->images()->saveMany($images);
}
Answer the question
In order to leave comments, you need to log in
Reduce by 2 times.
public static function contentSetImages(Category $category, $paths)
{
$images = [];
foreach ($paths as $path) {
$category->images()->create(['src' => $path]);
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question