单击提交按钮时,日期搜索不起作用

时间:2019-05-28 17:44:23

标签: laravel

我想使用created_at(开始日期和结束日期)进行搜索,但是它不起作用。它不显示结果

我已经开发了控制器和视图。我也写了查询来实现操作。

    public function detailSubscription(Request $request)
    {

    $detailsubscriptions = DB::table("users")
        ->select("plan",DB::raw("COUNT(plan) as total_plans") ,DB::raw("DATE(created_at) as date_subscribed"))
        ->groupBy("plan", "created_at")
        ->orderByRaw('DATE(created_at) DESC')
          ->paginate(15);

    $render=[];

        if(isset($request->start_date) && isset($request->end_date))
        {
            $detailsubscriptions=$detailsubscriptions->whereBetween('created_at',[$request->start_date,$request->end_date]);
            $render['start_date']=$request->start_date;
            $render['end_date']=$request->end_date;
        }elseif(isset($request->start_date))
        {
            $detailsubscriptions=$detailsubscriptions->where('created_at',$request->start_date);
            $render['start_date']=$request->start_date;
        }

         return view('report.detailSubscription', compact('detailsubscriptions'));        
    }       

视图

    <div class="row" style="margin-bottom: 10px">
        {{ Form::model(request(),['method'=>'get']) }}
        <div class="col-sm-4">
            {{ Form::date('start_date',null,['class'=>'form-control','placeholder'=>'Date']) }}

        </div>
        <div class="col-sm-4">
            {{ Form::date('end_date',null,['class'=>'form-control','placeholder'=>'Date']) }}
        </div>
        <div class="col-sm-4">
            {{ Form::submit('Search',['class'=>'btn btn-warning']) }}
            <a href="" class="btn btn-info">Export</a>
        </div>
        {{ Form::close() }}
    </div>


          <div class="box box-primary">
            <div class="box-header with-border">
        @if(Session::has('flash_message'))
        <div class="alert alert-success">
            {{ Session::get('flash_message') }}
        </div>
        @endif 

<table class="table table-bordered table-hover table-striped table-condesed" id="commenter_info_table">
    <tbody>
        @foreach($detailsubscriptions as $key => $detailsubscription)
            <tr>
                <td>{{ ++$key }}</td>
                <td><a href="">{{ $detailsubscription->date_subscribed }}</a></td>               
                <td>
                    {{ $detailsubscription->total_plans }}

                </td>

            </tr>

当我单击搜索提交按钮时,我希望能在表中看到结果,但是没有显示结果,也没有错误

0 个答案:

没有答案