1

我正在尝试生成从指定日期到指定日期的报告。

到目前为止一切正常。但是出现了这个错误,我必须在我的路由项目中使用可选的路由参数。

但是由于我不知道如何使用它,如果有人对此提供帮助,我将不胜感激。

这是我的前端数据表

    @extends('layout/master')
@section('content')

    <!-- header section -->
    <div class="box box-block bg-white">
        <div class="container  box-block" style="padding: 9px; margin-bottom: 9px;">
            <form action="" method="get">

                <div class="form-group col-md-4">
                    <label>From Date</label>
                    <input type="date" name="start" id="start" class="form-control">
                </div>
                <div class="form-group col-md-4">
                    <label>To Date</label>
                    <input type="date" name="end"  id="end" class="form-control">
                </div>
                <div class="form-group col-md-4">
                    <input type="submit" value="Search" class="btn btn-md  btn-primary" style="margin-top:26px;">
                </div>
            </form>
        </div>
    </div>


        <div class="box box-block bg-white">
            <div class="container">
                <!-- detail total -->

                <!-- table show details -->

                    <table class="table table-hover" id="report_table">
                        <thead>

                            <tr>
                                <th>ID</th>
                                <th>Name</th>
                                <th>Last Name</th>
                                <th>From</th>
                                <th>To</th>
                                <th>Bus-Model</th>
                                <th>Bus-Plate</th>
                                <th>Date</th>
                                <th>Seat NO</th>


                            </tr>
                        </thead>

                    </table>

            </div>
        </div>


@endsection


@section('script_code')

    <script type="text/javascript">

        $(function() {
        var table = $('#report_table').DataTable({

                'order' : [[0, 'desc']],
                'ajax' :{
                    "type" : "get",
                    "url"  : "{{ Route('xyz', request()->all())}}",
                },

                'columns': [


                    {'data' : 'id'},
                    {'data' : 'name'},
                    {'data' : 'lastname'},
                    {'data' : 'from'},
                    {'data' : 'to'},
                    {'data' : 'type'},
                    {'data' : 'plate'},
                    {'data' : 'date'},
                    {'data' : 'ch_id'},
                    // {'data' : 'action'  , orderable :false , searchable :false}


                ]


        });
    </script>
@endsection

这是我的控制器:

function get_report(Request $request, $start, $end){
  // return "From :" .$request->start . " |" .
  // "To :" .  $request->end;
      $data = DB::table('registration_tickets')
                ->join('trips', 'trips.id', 'registration_tickets.trip_id')
                ->join('buses', 'buses.id', 'trips.bus_id')
                ->join('drivers', 'drivers.id', 'trips.driver_id')
                ->join('routes', 'routes.id', 'trips.route_id')
                ->join('provinces as p1', 'p1.id', 'routes.from')
                ->join('provinces as p2', 'p2.id', 'routes.to') 
                ->select('registration_tickets.*', 'p1.name as from', 'p2.name as to', 'buses.type', 'buses.plate', 'drivers.name as d_name')
                ->whereBetween('registration_tickets.date',  [$start , $end])
                ->get();
return Datatables::of($data)->make(true);

这是我的路线:

Route::get('get_report/{start}/{end}', 'reportController@get_report')->name('xyz');
4

0 回答 0