|
...
|
...
|
@@ -216,15 +216,16 @@ class VideoTask extends Command |
|
|
|
$productIds[] = $item->id;
|
|
|
|
}
|
|
|
|
if (count($productIds)<7){
|
|
|
|
$product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",1)->pluck('id')->toArray();
|
|
|
|
$product_id = array_rand($product_all_id, 40-count($productIds));
|
|
|
|
$product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
|
|
|
|
$number = 40;
|
|
|
|
$product_id = array_rand($product_all_id, min(count($product_all_id, $number-count($productIds))));
|
|
|
|
$randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
|
|
|
|
$products = $productsQuery->merge($randomData);
|
|
|
|
}else{
|
|
|
|
$products = $productsQuery;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$product_all_id = Product::where("project_id", $project_id)->where("status",1)->pluck('id')->toArray();
|
|
|
|
$product_all_id = Product::where("project_id", $project_id)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
|
|
|
|
$product_id = array_rand($product_all_id, 40);
|
|
|
|
$products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
|
|
|
|
}
|
...
|
...
|
|