为什么已发布的会议不出现?

时间:2018-07-29 02:08:22

标签: php laravel

我在下面使用此查询来获取已发布的会议:

$publishedConferences =
            $user->conferences()->
            where(function ($query) {
                $query->where('status', '=', 'P');
                $query->where('end_date','>', now());
            })
                ->paginate($pageLimit);

        dd($publishedConferences);

但是$ publishedConferences显示:

LengthAwarePaginator {#345 ▼
  #total: 1
  #lastPage: 1
  #items: Collection {#344 ▶}
  #perPage: 5
  #currentPage: 2
  #path: "https://proj.test/user/profile"
  #query: []
  #fragment: null
  #pageName: "page"
}

因此没有会​​议出现。但是,在数据库中,有一个会议的状态等于“ P”,而“ end_date”为“ now()”。

您知道可能是什么问题吗?

已发布会议出现的HTML:

<div class="tab-pane fade show clearfix" id="publishedConferences" role="tabpanel"
 aria-labelledby="home-tab">
    <ul class="list-group">
        @foreach($publishedConferences as $publishedConference)
            @if(!empty($publishedConference))
                <li class="list-group-item">
                    <p>{{$publishedConference->start_date->formatLocalized('%a, %b %d, %Y - %H:%M')}}</p>
                    <h5>{{$publishedConference->name}}</h5>
                </li>
            @endif
        @endforeach
    </ul>

    <div class="text-center d-flex justify-content-center mt-3">
        {{$publishedConferences->fragment('publishedConferences')->links("pagination::bootstrap-4")}}

    </div>
</div>

1 个答案:

答案 0 :(得分:0)

将where子句更改为:

 // or toDateTimeString() if needed for datetime type column
 $query->where('end_date','>', now()->toDateString());