我有一个页面,在那里生活和过去的论文都应该显示,但当实时论文时间到期时,实时论文不应该被加载,只有过去的论文应该显示基于时间。当前使用的查询,
$curdate=Carbon::now();
$papers = DB::table('papers')
->join('payments','papers.id','=','payments.paper_id')
->join('tutors','papers.tutor_id','tutors.id')
->select('papers.*','tutors.name')
->where('papers.id','payments.paper_id')
->where('papers.type','=','Normal')
->orWhere('papers.live_end_time', '>=' ,$curdate)
->where('payments.user_id',$id)
->get();这将显示实时论文,但不显示过去的论文。当时间到期时,实时文件被隐藏起来。当我更换了where和orWhere子句的位置时,显示了过去的论文,但没有显示实时论文,为什么会发生这种情况,以及它们的修复方法。
发布于 2018-03-29 17:25:59
我认为您为orWhere语句设置了错误的条件,请尝试使用->orWhere('papers.live_end_time', '<=' ,$curdate),这样它就可以完成您想要实现的任务
https://stackoverflow.com/questions/49551720
复制相似问题