80 lines
2.4 KiB
PHP
80 lines
2.4 KiB
PHP
<?php
|
|
namespace App\Services\SyS;
|
|
|
|
use Carbon;
|
|
use Request;
|
|
use App\Models\SySetting;
|
|
use App\Models\ProductBuying;
|
|
use App\Cron\BusinessUsersStore;
|
|
use App\Models\ShoppingOrderItem;
|
|
|
|
class BuyingsProducts
|
|
{
|
|
|
|
public static function show()
|
|
{
|
|
|
|
$data = [
|
|
];
|
|
|
|
return view('sys.tools.buyings_products', $data);
|
|
}
|
|
|
|
|
|
public static function store()
|
|
{
|
|
|
|
$ShoppingOrderItems = ShoppingOrderItem::where('product_id', 37)->get();
|
|
$count = 0;
|
|
foreach($ShoppingOrderItems as $ShoppingOrderItem){
|
|
if(!ProductBuying::where('user_id', $ShoppingOrderItem->shopping_order->auth_user_id)->where('product_id', $ShoppingOrderItem->product_id)->count()){
|
|
ProductBuying::create([
|
|
'user_id' => $ShoppingOrderItem->shopping_order->auth_user_id,
|
|
'product_id' => 37,
|
|
'amount' => 1
|
|
]);
|
|
$count ++;
|
|
}
|
|
|
|
}
|
|
dump("ADD ".$count." product_id 37");
|
|
|
|
$ShoppingOrderItems = ShoppingOrderItem::where('product_id', 100)->get();
|
|
$count = 0;
|
|
foreach($ShoppingOrderItems as $ShoppingOrderItem){
|
|
if(!ProductBuying::where('user_id', $ShoppingOrderItem->shopping_order->auth_user_id)->where('product_id', $ShoppingOrderItem->product_id)->count()){
|
|
ProductBuying::create([
|
|
'user_id' => $ShoppingOrderItem->shopping_order->auth_user_id,
|
|
'product_id' => 118,
|
|
'amount' => 1
|
|
]);
|
|
$count ++;
|
|
}
|
|
|
|
}
|
|
dump("ADD ".$count." product_id 100 to 118");
|
|
|
|
|
|
$ShoppingOrderItems = ShoppingOrderItem::where('product_id', 118)->get();
|
|
$count = 0;
|
|
foreach($ShoppingOrderItems as $ShoppingOrderItem){
|
|
if(!ProductBuying::where('user_id', $ShoppingOrderItem->shopping_order->auth_user_id)->where('product_id', $ShoppingOrderItem->product_id)->count()){
|
|
ProductBuying::create([
|
|
'user_id' => $ShoppingOrderItem->shopping_order->auth_user_id,
|
|
'product_id' => 118,
|
|
'amount' => 1
|
|
]);
|
|
$count ++;
|
|
}
|
|
|
|
}
|
|
dump("ADD ".$count." product_id 118");
|
|
|
|
|
|
die();
|
|
|
|
\Session()->flash('alert-save', '1');
|
|
return redirect(route('sysadmin_tool', ['buyings_products']));
|
|
|
|
}
|
|
}
|