获取缺货商品合计,总价添加到用户库存记录laravel
Get total of out of stock products, total price added to the inventory records for the user laravel
所以我有这种情况,我有一个项目 table
Schema::create('items', function (Blueprint $table) {
$table->id();
$table->string("name", 255)->index();
$table->float("price");
$table->foreignId("business_id")->constrained()->cascadeOnDelete();
$table->float('selling_price')->after('price');
$table->bigInteger('quantity_in_stock')->after('price')->nullable();
$table->boolean('unlimited')->after('quantity_in_stock')->default(false);
$table->timestamp("last_purchase_date")->nullable();
$table->timestamps();
});
所以我想 return 使用他创建的业务的特定用户的项目
我想计算总价,库存数量为零的产品总数。
请帮忙
DB::table('itmes')
->select('business_id',DB::raw('count(*) as total_number, sum('price') as total_price'))
->where('quantity_in_stock', 0)
->groupBy('business_id')
->get();
所以我有这种情况,我有一个项目 table
Schema::create('items', function (Blueprint $table) {
$table->id();
$table->string("name", 255)->index();
$table->float("price");
$table->foreignId("business_id")->constrained()->cascadeOnDelete();
$table->float('selling_price')->after('price');
$table->bigInteger('quantity_in_stock')->after('price')->nullable();
$table->boolean('unlimited')->after('quantity_in_stock')->default(false);
$table->timestamp("last_purchase_date")->nullable();
$table->timestamps();
});
所以我想 return 使用他创建的业务的特定用户的项目 我想计算总价,库存数量为零的产品总数。 请帮忙
DB::table('itmes')
->select('business_id',DB::raw('count(*) as total_number, sum('price') as total_price'))
->where('quantity_in_stock', 0)
->groupBy('business_id')
->get();