2 weeks ago

Add Quantity on order menu

Posted 2 weeks ago by SHAIK

on clicking item it adds one qty by default and when i click on same item its adding another line instead of increasing qty below is my code can any one help me in this.

    // if there is no sale for the selected table, create a new sale record
        $user = Auth::user();
        $sale = new Sale();
        $sale->table_id = $table_id;
        $sale->table_name = $table_name;
        $sale->user_id = $user->id;
        $sale->user_name = $user->name;
        $sale_id = $sale->id;
        // update table status
        $table = Table::find($table_id);
        $table->status = "unavailable";
   else{ // if there is a sale on the selected table
        $sale_id = $sale->id;

    // add ordered menu to the sale_details table
    $saleDetail = new SaleDetail();
    $saleDetail->sale_id = $sale_id;
    $saleDetail->menu_id = $menu->id;
    $saleDetail->menu_name = $menu->name;
    $saleDetail->menu_price = $menu->price;
    $saleDetail->quantity = ($request->quantity);
    //update total price in the sales table
    $sale->total_price = $sale->total_price + ($request->quantity * $menu->price);

Please sign in or create an account to participate in this conversation.