Laravel 4 Laravel日期选择器和雄辩的查询

Laravel 4 Laravel日期选择器和雄辩的查询,laravel-4,eloquent,jquery-ui-datepicker,laravel-routing,Laravel 4,Eloquent,Jquery Ui Datepicker,Laravel Routing,我正在制作一个页面,在那里我可以使用来自jqueryui.com的date ranger和date Picker,我非常熟悉laravel框架 我有如下雄辩的疑问: public function orderbydate() { $order =DB::table('sales_flat_order_items as s') ->leftJoin('sales_flat_orders as w', 'w.entity_id','=','s.order_id

我正在制作一个页面,在那里我可以使用来自jqueryui.com的date ranger和date Picker,我非常熟悉laravel框架

我有如下雄辩的疑问:

public function orderbydate()
{

    $order =DB::table('sales_flat_order_items as s')
            ->leftJoin('sales_flat_orders as w', 'w.entity_id','=','s.order_id')
            ->select(array(DB::Raw('sum(s.amount_refunded) as amount_refunded'),
                DB::Raw('sum(s.row_total) as row_total'),
                DB::Raw('sum(s.discount_amount) as discount_amount'),
                DB::Raw('sum(s.tax_amount) as tax_amount'),
                DB::Raw('sum(s.qty_ordered) as qty_ordered'),
                DB::Raw('sum(w.subtotal) as subtotal'), 
                DB::Raw('sum(w.total_invoiced) as total_invoiced'), 
                DB::Raw('sum(w.shipping_amount) as shipping_amount')))
            ->where('qty_canceled','=','0')
            ->where('status','!=','canceled')
            ->get();

    $orderbydate = DB::table('sales_flat_order_items as s')
            ->leftJoin('sales_flat_orders as w', 'w.entity_id','=','s.order_id')
            ->select(array(DB::Raw('sum(s.amount_refunded) as amount_refunded'),
                DB::Raw('sum(s.row_total) as row_total'),
                DB::Raw('sum(s.discount_amount) as discount_amount'),
                DB::Raw('sum(s.tax_amount) as tax_amount'),  
                DB::Raw('sum(s.qty_ordered) as qty_ordered'),
                DB::Raw('sum(w.subtotal) as subtotal'),
                DB::Raw('DATE(w.created_at) days'), 
                DB::Raw('sum(w.total_invoiced) as total_invoiced'),
                DB::Raw('sum(w.shipping_amount) as shipping_amount')))
            ->where('qty_canceled','=','0')
            ->where('status','!=','canceled')
            ->groupBy('days')
            ->orderBy('s.created_at')
            ->paginate(10);

        return View::make('sales_flat_orders.orderbydate', compact('order','orderbydate'));
}
注意:此函数将显示模板上的所有数据

另一个功能是

public function orderbydate1()
    {
        $startDate = Input::get('w.created_at');
        $endDate = Input::get('w.created_at');

        $order1 =DB::table('sales_flat_order_items as s')
                ->leftJoin('sales_flat_orders as w', 'w.entity_id','=','s.order_id')
                ->select(array(DB::Raw('sum(s.amount_refunded) as amount_refunded'),
                    DB::Raw('sum(s.row_total) as row_total'),
                    DB::Raw('sum(s.discount_amount) as discount_amount'),
                    DB::Raw('sum(s.tax_amount) as tax_amount'),
                    DB::Raw('sum(s.qty_ordered) as qty_ordered'),
                    DB::Raw('sum(w.subtotal) as subtotal'), 
                    DB::Raw('sum(w.total_invoiced) as total_invoiced'), 
                    DB::Raw('sum(w.shipping_amount) as shipping_amount')))
                ->where('qty_canceled','=','0')
                ->where('status','!=','canceled')
                ->get();

        $orderbydate1 = DB::table('sales_flat_order_items as s')
                ->leftJoin('sales_flat_orders as w', 'w.entity_id','=','s.order_id')
                ->select(array(DB::Raw('sum(s.amount_refunded) as amount_refunded'),
                    DB::Raw('sum(s.row_total) as row_total'),
                    DB::Raw('sum(s.discount_amount) as discount_amount'),
                    DB::Raw('sum(s.tax_amount) as tax_amount'),  
                    DB::Raw('sum(s.qty_ordered) as qty_ordered'),
                    DB::Raw('sum(w.subtotal) as subtotal'),
                    DB::Raw('DATE(w.created_at) days'), 
                    DB::Raw('sum(w.total_invoiced) as total_invoiced'),
                    DB::Raw('sum(w.shipping_amount) as shipping_amount')))
                ->whereBetween('w.created_at',array($startDate,$endDate))
                ->where('qty_canceled','=','0')
                ->where('status','!=','canceled')
                ->groupBy('days')
                ->orderBy('s.created_at')
                ->paginate(10);

            return View::make('sales_flat_orders.result', compact('order','orderbydate1'));
    }
我有一个名为OrderByDAte.blade.php的模板

按日期列出的销售额 但是这个功能不起作用

我目前正在使用引导日期选择器。但是如果你知道另一个,你可以给我举个例子

现在有两个模板,我用于

Route::get('orderbydate', array('as'=>'orderbydate', 'uses'=>'SalesFlatController@orderbydatesales'))
将所有数据放入我的模板

我用这个职位

Route::get('result', array('as'=>'result', 'uses'=>'SalesFlatController@orderbydate'))
注意:我得到一个错误,比如缺少1个参数

谁能帮我一点忙,让我知道哪里出了问题

您需要更改:

public function orderbydate($startDate, $endDate)
致:

当您从
Input::get()
获取这些值时。只有当这些变量来自路由中的变量时,您才会将这些变量放入函数调用中,即:

Route::get('result/{startDate}/{endDate}', array('as'=>'result', 'uses'=>'SalesFlatController@orderbydate'))

嘿@ceejayoz,我已经在我的帖子中添加了更多的信息。你能看一下吗。实际上,我在单击“提交”后得到methodnotallowedexception。@酷,你得到methodnotallowedexception是因为你正在
POST
GETroute。是@ceejayoz。对,我明白了。你能给我解释一下这两者之间的关系吗?我的意思是这里没有接收输入。我看到了sql查询,它显示为空,w在“”和“”之间创建,如图所示。您在哪里看到了查询?如果打印出查询日志,它将有
占位符。假设您提供的是MySQL的日期格式
YYYY-MM-DD HH:ii:ss
,那么
whereBetween
的实现就可以了。
Route::get('result', array('as'=>'result', 'uses'=>'SalesFlatController@orderbydate'))
public function orderbydate($startDate, $endDate)
public function orderbydate()
Route::get('result/{startDate}/{endDate}', array('as'=>'result', 'uses'=>'SalesFlatController@orderbydate'))