如果要在 Laravel 上使用 Carbon 比较两个日期,一个来自 table 的日期和一个 now() 实例

If to compare two dates using Carbon on Laravel, a date from a table and a now() instance

我正在尝试显示 table 中的一些项目并且我在它们开始时订购,我只想显示从 now() 开始的接下来的三个项目。这是我的控制器功能:

可能整个事情都是完全错误的,但是,我们将不胜感激任何帮助。

  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'));
        }

    }
 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'));
     }