I am trying to retrieve my result and every day every service have how much total charged, total refund. My logic not work properly cause of where condition.I cant understand.
My code
$transactions = Transaction::with('service')
->select('id','transaction_no','created_at','service_id')
->selectRaw(DB::raw('sum(deducted) as success where refund = 0'))
->addSelect(DB::raw('sum(charges) as charges'))
->addSelect(DB::raw('sum(deducted) as refunded where refund != 0'));
$transactions = $transactions->groupBy('service_id',DB::raw('DATE(created_at)'))->get();
return $transactions->toJson(JSON_PRETTY_PRINT);
I think issue is where refund != 0' and where refund = 0'
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2BTqJHG
via IFTTT
Aucun commentaire:
Enregistrer un commentaire