vendredi 27 octobre 2017

(2/2) ErrorException Object of class stdClass could not be converted to int in laravel 5

Actually i want to create a tax summary of invoice in which i want to add total according to different tax rate.For example:- 2.5% taxrate has its own products and 6% taxrate has its own product.i want to do this in for loop.I have used following code but it did not work.please tell me what is wrong in this code.it did not show correct total.I have a table name is sales_items.Its field are id,invoice_id,cgst_percentage,cgst_amount,sgst_percentage etc [![enter image description here][1]][1] In Controller

    $data['query1']= DB::table('sales_items')->distinct()->get(['cgst_percentage']);
    I am using this variable in foreach loop in view file.

    **In view.blade.php file**

    <?php $data_total= array();  ?>
     <?php $cgst_unique_data= array(); ?>

     @foreach($query1 as $cgst_data=>$value)


    <?php 

    $cgst_unique_data= DB::table('sales_items')->where('cgst_percentage','=',$value->cgst_percentage)->where('invoice_id','=',$sales_item->invoice_id)->get();

    ?>

     @foreach($cgst_unique_data as $total=>$value) 

     <?php

    $data_total = $total_amount + $total;
     $data_total= $data_total + $value;
     ?> 
     @endforeach

    

 @endforeach


  [1]: http://ift.tt/2hgUlFl



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire