Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery Laravel 5.6中的日期时间范围搜索_Jquery_Html_Laravel - Fatal编程技术网

Jquery Laravel 5.6中的日期时间范围搜索

Jquery Laravel 5.6中的日期时间范围搜索,jquery,html,laravel,Jquery,Html,Laravel,我正在表格中显示我的数据。在我的故事里我有一段重要的时光。现在我想过滤两个日期之间的数据。我添加了jquery日期时间选择器from date和to date。但我很困惑,在同一个表中只显示日期范围数据,默认情况下,该表显示所有数据。有人能给我建议一下日期范围过滤器的模型视图和控制器的确切方式吗 日期范围输入 剧本 您需要将“从到”范围分为两个单独的条件: 使用碳\碳; ... $query=InternalVisitor::query; 如果请求->具有“发件人”{ $from=Carbon:

我正在表格中显示我的数据。在我的故事里我有一段重要的时光。现在我想过滤两个日期之间的数据。我添加了jquery日期时间选择器from date和to date。但我很困惑,在同一个表中只显示日期范围数据,默认情况下,该表显示所有数据。有人能给我建议一下日期范围过滤器的模型视图和控制器的确切方式吗

日期范围输入

剧本

您需要将“从到”范围分为两个单独的条件:

使用碳\碳; ... $query=InternalVisitor::query; 如果请求->具有“发件人”{ $from=Carbon::parserequest->get'from'->格式为'Y-m-d'。'00:00:00'; $query->where'signetime','>=',$from; } 如果请求->有“to”{ $to=Carbon::parserequest->get'to'->格式为'Y-m-d'。'23:59:59';
$query->where'signInTime',它现在显示FatalThrowableError E_对Strings上的成员函数日期的错误调用我只是复制粘贴了你的代码,假设它正常工作。你可以使用Carbon解析传入的字符串datetime值。我更新了答案。我使用Carbon,但它向我显示datetime:\u构造:解析时间字符串失败2018年8月27日-下午5点28分位置15-:意外字符现在我查看了您的代码,您的日期时间选择器使用Y-m-d H:I:s格式,因此您可以直接将其输入到查询中:$query->where'signetime','>=',request->get'from';
<div class="col-md-4">
<div class="input-group date form_meridian_datetime" data-date="2012-12-21T15:25:00Z">
    <input type="text" placeholder="from" name="from" id="from" size="16" class="form-control">
    <span class="input-group-btn">
        <button class="btn default date-reset" type="button">
        <i class="fa fa-times"></i>
        </button>
        <button class="btn default date-set" type="button">
        <i class="fa fa-calendar"></i>
        </button>
    </span>
</div>
<table class="table table-striped table-bordered table-hover" id="sample_3">
        <thead>
            <tr>
                <th> Permit Taker </th>
                <th> Permit By </th>
                <th> Permit Types </th>
                <th> Purpose </th>
                <th> Entry Date &Time </th>
                <th> Exit Date & Time </th>
                <th> SignIn </th>
                <th> SignOut </th>
                <th> Edit </th>
                <th> Delete </th>
            </tr>
        </thead>
        <tbody>
            @foreach($internalVisitors as $internalVisitor)
            <tr>
                <td> {{ $internalVisitor->internalHosts->hostName }} </td>
                <td> {{ $internalVisitor->permitBy}} </td>
                <td> {{ $internalVisitor->permitType}} </td>
                <td> {{ $internalVisitor->purpose}} </td>
                <td> {{ $internalVisitor->startDate}} </td>
                <td> {{ $internalVisitor->endDate}} </td>

                <td>
                    @if ( $internalVisitor-> signIn === 1)
                    <span >{{ $internalVisitor->signInTime}}</span>
                    @else
                    <form method="post" action="{{route('signInUpdate','id')}}">
                        {{ csrf_field()}}
                        <input type="hidden" name="isSignIn" value="{{$internalVisitor->isSignIn}}"/>
                        <input type="hidden" name="tableId" value="{{$internalVisitor->id}}"/>
                        <button type="submit">
                        <a >Sign In</a></button>

                    </form>
                    @endif
                </td>
                <td>

                    @if( $internalVisitor->signIn === 0)
                    <span>Not SignIn</span>

                    @elseif ($internalVisitor-> signIn === 1 && $internalVisitor->signOut === 1)
                    <span>{{ $internalVisitor->signOutTime}}</span>
                    @elseif($internalVisitor-> signIn === 1 && $internalVisitor->signOut === 0 )
                    <form method="post" action="{{route('signOutUpdate','id')}}">
                        {{ csrf_field()}}
                        <input type="hidden" name="signOut" value="{{$internalVisitor->signOut}}"/>
                        <input type="hidden" name="tableId" value="{{$internalVisitor->id}}"/>
                        <button type="submit">

                    </form>
                    <a >Sign Out</a></button>

                    @endif
                </td>
                <td class=""><a class="btn btn-raised btn-primary btn-sm" href="{{ route('iVisitorEdit',
                $internalVisitor->id) }}"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></a>
            </td>
            <td>
                <form method="POST" id="delete-form-{{ $internalVisitor->id }}" action="{{ route('iVisitorDelete',$internalVisitor->id) }}" style="display: none;">
                    {{ csrf_field() }}
                    {{ method_field('delete') }}

                </form>

                <button onclick="if(confirm('Are you Sure, You went to delete this?')){
                event.preventDefault();
                document.getElementById('delete-form-{{ $internalVisitor->id }}').submit();
                }else{
                event.preventDefault();
                }" class="btn btn-raised btn-danger btn-sm"><i class="fa fa-trash-o" aria-hidden="true"></i></button>
            </td>

        </tr>
        @endforeach


    </tbody>
</table>
if (request()->has('from') && request()->has('to')) {
        $from = request()->get('from')->date('Y-m-d' . ' 00:00:00', time()); 
        $to = request()->get('to')->date('Y-m-d' . ' 00:00:00', time()); 

        $leads = InternalVisitor::whereBetween('signInTime', [$from, $to])->paginate(5);
        dd($leads);

    }
    <script>
$(document).ready(function(){
    $.datepicker.setDefaults({
        dateFormat: 'Y-m-d H:i:s'
    });
    $(function(){
        $("#From").datepicker();
        $("#to").datepicker();
    });
    $('#range').click(function(){
        var From = $('#From').val();
        var to = $('#to').val();
        if(From != '' && to != '')
        {
            $.ajax({
                url: '{{route('internalVisitor')}}',
                method:"POST",
                data:{From:From, to:to},
                success:function(data)
                {
                    $('#sample_3').html(data);
                }
            });
        }
        else
        {
            alert("Please Select the Date");
        }
    });
});
</script>