Hi, all. I want to sum a field in the database(via query builder) based on a condition (ie. date<6/11/2016) and don't know which way is the best. I'm doing like this, is there any other better way to do this.
$income = DB::table('incomes') ->join('currencies', 'currencies.cur_id','=','incomes.currency_id') ->selectRaw('incomes.*, currencies.currency ,sum(incomes.total) as total') ->where('inc_date','>',$sd)->where('inc_date','<',$ed)->get(); return view('report.report', compact('income','sd','ed'))->render();
Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.