我正在尝试通过将日期的到期日期与今天的日期进行比较来过滤一组对象,但我无法让它正常工作。任何人都可以看看代码。我确定我在这里遗漏了一些东西。我到处搜索,发现了很多例子,但没有一个有效。
这符合得很好,但包含 9 个对象的列表,其中 3 个对象的到期日期设置为 2012,它不会从集合中返回任何结果。
控制器
public function classifieds()
{
$myclassifieds = Auth::user()->classifieds;
return view('account.classifieds')->with(['allclassifieds'=>$myclassifieds]);
}
看法
@if(count($allclassifieds->where('expired_on','<', Carbon\Carbon::now() ) ) > 0)
//Something here
@endif