lundi 5 août 2019

Laravel collection sum A non-numeric value encountered Error

I was trying to find sum of specific column of a collection. I used the following code to use but the problem is it throws following Error:

(1/1) ErrorException A non-numeric value encountered

$query = DB::table('transactions')
     ->join('customers','transactions.customer_id','customers.id')
     ->select('transactions.collected_today','transactions.due','customers.service_id')
     ->whereYear('transactions.updated_at', date('Y')) 
     ->groupBy('transactions.customer_id');

$yearly_report = $query->get();
$total_collection = $yearly_report->sum('collected_today');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire