如何在保存到数据库之前检查我的数量

时间:2017-09-30 03:05:28

标签: php laravel laravel-5.3

如何查看我的v_total_quantity.total_quantity_box < $request->input('quantity_box')[$i];

当我在这里提交数据是我的桌子和我的控制器

    id_w | id_p  | product_name| total_quantity_box
    10   | 1     | snack       |10
    10   | 2     | watebottle  |10   
    10   | 3     | headphone   |10


  for ($i=0; $i < $count; $i++) {
        $warehouse_products_sell = New Warehouse_products_sell;
        $warehouse_products_sell->id_w = $request->input('idw');
        $warehouse_products_sell->id_c = $request->get('id_c')[$i];
        $warehouse_products_sell->id_p = $request->get('id_p')[$i];
        $warehouse_products_sell->quantity_box = $request->input('quantity_box')[$i];
        $warehouse_products_sell->price = $request->input('price')[$i];
        $warehouse_products_sell->serial_num = $a;
        $a = DB::table('v_total_quantity')
                ->select([
                'v_total_quantity.id_w',
                'v_total_quantity.id_p',
                'v_total_quantity.total_quantity_box',
                'products.product_name',
                'products.product_unit',
                'products.id_product',
             ])
            ->leftjoin('products', 'v_total_quantity.id_p', '=', 'products.id_p')
            ->where([
                ['v_total_quantity.id_w', '=', $request->input('idw')],
                ['v_total_quantity.id_p', '=', $request->input('quantity_box')],
                ]);

        // if ($a->id_p < $request->input('quantity_box')) {
        //     echo "success";
        // }else{
        //     echo "error";
        // }
        // $warehouse_products_sell->save();
    }

但它不起作用

在我的blade_temp中我使用了动态添加,这就是为什么我要去[$ i]

 <select style="width:48%;" class="productname" name="id_p[]">
  <option value="0" disabled="true" selected="true"> Product Name</option>
 </select>

我想确保我的total_quantity_box不是 -

0 个答案:

没有答案