app/Http/Controllers/QuantityInventoryController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $orderToken=new orderToken;
        $orderSumHistory=new orderSumHistory;
        $quantityRemark=new quantityRemark;
        $allRequest=$request->all()['data'];
        foreach($allRequest as $key=>$data){
            $orderHistoryData = $data;
            $remaining_quantity=$orderHistoryData['remaining_quantity'];
            unset($orderHistoryData['subtotal']);
            unset($orderHistoryData['discount']);
            unset($orderHistoryData['total_price']);
            unset($orderHistoryData['catalog_id']);
            unset($orderHistoryData['current_quantity']);
            unset($orderHistoryData['seller_name']);
            unset($orderHistoryData['customer_type']);
            unset($orderHistoryData['order_time']);
            unset($orderHistoryData['cash_tendered']);
            unset($orderHistoryData['change_due']);
            unset($orderHistoryData['remaining_quantity']);
            unset($orderHistoryData['token_no']);
            orderHistory::insert([$orderHistoryData]);
            $catalog_id=$data["catalog_id"];
            catalogQuantity::where('catalog_id', $catalog_id)->update(['quantity' => $remaining_quantity]);
            $catalogQuantityId=catalogQuantity::select('id')->where('catalog_id', $catalog_id)->get()->toArray()[0]['id'];
            $modifiedQuantity=$data['current_quantity']-$data['remaining_quantity'];
            $CurrentOrderid=$data['order_id'];
            $quantityRemark->firstOrCreate(['quantity_id' => $catalogQuantityId, 'modified_quantity' => $modifiedQuantity, 'input_type' => 3, 'remarks' => auth::user()->name . " created an order. Order no " . $CurrentOrderid, 'user' => auth::user()->name]);
        }
        $orderToken->curr_token_no=$request->all()['data'][0]["token_no"];
        $orderToken->token_date=Carbon::now('Asia/Dhaka')->format('Y-m-d');
        $orderToken->save();
        $orderSumHistory->order_id=$request->all()['data'][0]["order_id"];
        $orderSumHistory->token_no=$request->all()['data'][0]["token_no"];
        $orderSumHistory->subtotal=$request->all()['data'][0]["subtotal"];
        $orderSumHistory->order_time=$request->all()['data'][0]["order_time"];
        $orderSumHistory->seller_name=$request->all()['data'][0]["seller_name"];
        $orderSumHistory->customer_type=$request->all()['data'][0]["customer_type"];
        $orderSumHistory->Total_discount=$request->all()['data'][0]["discount"];
        $orderSumHistory->total_price=$request->all()['data'][0]["total_price"];
        $orderSumHistory->cash_tendered=$request->all()['data'][0]["cash_tendered"];
        $orderSumHistory->change_due=$request->all()['data'][0]["change_due"];
        $orderSumHistory->order_status=1;
        $orderSumHistory->save();
        return 1;
    }
public function store ( Request $ request ) { $ orderToken = new orderToken ; $ orderSumHistory = new orderSumHistory ; $ quantityRemark = new quantityRemark ; $ allRequest = $ request -> all ( ) [ 'data' ] ; foreach ( $ allRequest as $ key => $ data ) { $ orderHistoryData = $ data ; $ remaining_quantity = $ orderHistoryData [ 'remaining_quantity' ] ; unset ( $ orderHistoryData [ 'subtotal' ] ) ; unset ( $ orderHistoryData [ 'discount' ] ) ; unset ( $ orderHistoryData [ 'total_price' ] ) ; unset ( $ orderHistoryData [ 'catalog_id' ] ) ; unset ( $ orderHistoryData [ 'current_quantity' ] ) ; unset ( $ orderHistoryData [ 'seller_name' ] ) ; unset ( $ orderHistoryData [ 'customer_type' ] ) ; unset ( $ orderHistoryData [ 'order_time' ] ) ; unset ( $ orderHistoryData [ 'cash_tendered' ] ) ; unset ( $ orderHistoryData [ 'change_due' ] ) ; unset ( $ orderHistoryData [ 'remaining_quantity' ] ) ; unset ( $ orderHistoryData [ 'token_no' ] ) ; orderHistory :: insert ( [ $ orderHistoryData ] ) ; $ catalog_id = $ data [ " catalog_id " ] ; catalogQuantity :: where ( 'catalog_id' , $ catalog_id ) -> update ( [ 'quantity' => $ remaining_quantity ] ) ; $ catalogQuantityId = catalogQuantity :: select ( 'id' ) -> where ( 'catalog_id' , $ catalog_id ) -> get ( ) -> toArray ( ) [ 0 ] [ 'id' ] ; $ modifiedQuantity = $ data [ 'current_quantity' ] - $ data [ 'remaining_quantity' ] ; $ CurrentOrderid = $ data [ 'order_id' ] ; $ quantityRemark -> firstOrCreate ( [ 'quantity_id' => $ catalogQuantityId , 'modified_quantity' => $ modifiedQuantity , 'input_type' => 3 , 'remarks' => auth :: user ( ) -> name . "  created an order. Order no  " . $ CurrentOrderid , 'user' => auth :: user ( ) -> name ] ) ; } $ orderToken -> curr_token_no = $ request -> all ( ) [ 'data' ] [ 0 ] [ " token_no " ] ; $ orderToken -> token_date = Carbon :: now ( 'Asia/Dhaka' ) -> format ( 'Y-m-d' ) ; $ orderToken -> save ( ) ; $ orderSumHistory -> order_id = $ request -> all ( ) [ 'data' ] [ 0 ] [ " order_id " ] ; $ orderSumHistory -> token_no = $ request -> all ( ) [ 'data' ] [ 0 ] [ " token_no " ] ; $ orderSumHistory -> subtotal = $ request -> all ( ) [ 'data' ] [ 0 ] [ " subtotal " ] ; $ orderSumHistory -> order_time = $ request -> all ( ) [ 'data' ] [ 0 ] [ " order_time " ] ; $ orderSumHistory -> seller_name = $ request -> all ( ) [ 'data' ] [ 0 ] [ " seller_name " ] ; $ orderSumHistory -> customer_type = $ request -> all ( ) [ 'data' ] [ 0 ] [ " customer_type " ] ; $ orderSumHistory -> Total_discount = $ request -> all ( ) [ 'data' ] [ 0 ] [ " discount " ] ; $ orderSumHistory -> total_price = $ request -> all ( ) [ 'data' ] [ 0 ] [ " total_price " ] ; $ orderSumHistory -> cash_tendered = $ request -> all ( ) [ 'data' ] [ 0 ] [ " cash_tendered " ] ; $ orderSumHistory -> change_due = $ request -> all ( ) [ 'data' ] [ 0 ] [ " change_due " ] ; $ orderSumHistory -> order_status = 1 ; $ orderSumHistory -> save ( ) ; return 1 ; }
Store a newly created resource in storage.
Store a newly created resource in storage .