我正在使用具有DateRange脚本形式jQuery和bootstrap的表
我对此没有任何问题。我要实现的是显示Amount和groupBy货币的总和。所以我在Fetch_data函数中添加了另一个条件。
public function fetch_data(Request $request)
{
if($request->ajax())
{
if($request->from_date != '' && $request->to_date != '')
{
$data = Sales::with('companies','Currencies')->where('publish','=',1)
->whereBetween('created_at', array($request->from_date, $request->to_date))
->get();
} else {
$sales = Sales::where('publish','=',1)->get();
}
echo json_encode($data);
// I WANT TO INCLUDE THIS THE RESULT IN MY BLADE. HOW?
if($request->from_date != '' && $request->to_date != '')
{
$currencyTotal = DB::table('sales')
->whereBetween('create_at', [$request->from_date, $request->to_date])
->selectRaw('sum(grandtotal')
->selectRaw('id')
->groupBy('currency_id')
->get();
}
echo json_encode($currencyTotal);
}
}
但这不起作用...有什么想法吗?预先感谢!