jeudi 6 septembre 2018

get total of the column with where condition

I am trying to get the total of the column Price with condition BillPaid column value should be 0.

My code block is

public function countDue()
{
    $getTotalDue = DB::table('ordered_books')                                
                            ->where('BillPaid', 0)
                            ->sum('Price')
                            ->get(); 
    return response()->json($getTotalDue);
    return compact('getTotalDue');
}

but I am getting error as :

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Call to a member function get() on float

My table structure is:

enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire