【发布时间】:2019-01-05 16:24:36
【问题描述】:
我有以下查询以获取已发布的会议:
$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>
【问题讨论】: