在Laravel中使用引导程序和jQuery dateRange脚本在单个dateRange动作中使用多个方法或函数

时间:2019-03-27 18:16:16

标签: jquery laravel twitter-bootstrap

我正在使用具有DateRange脚本形式jQuery和bootstrap的表

enter image description here

我对此没有任何问题。我要实现的是显示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);       
    }
}

但这不起作用...有什么想法吗?预先感谢!

0 个答案:

没有答案