我试图从表格中显示一些项目,并且我们在开始时排序,我只想显示从现在开始的下三个项目()。这是我的控制器功能:
可能整件事情完全错了,但是,任何帮助都会受到高度赞赏。
public function next(Request $request)
{
$eventos = Event::orderBy('start','asc');
$eventTime = Carbon::createFromDate($eventos->start);
$mytime = Carbon::now();
if($eventTime > $mytime){
$eventos = paginate(3);
return view('evento.next',compact('eventos'));
}
}
答案 0 :(得分:0)
public function next(Request $request)
{
$eventos=Event::where('start','>=',Carbon::now()) // select all recodrs where start Time more than now date
->orderBy('start','asc') // order all records by asc
->take(3) // take first 3 record
->get(); // now get the result
return view('evento.next',compact('eventos'));
}