dimanche 30 avril 2017

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

I'm trying to display some items from a table and I'm ordering by the time they begin, I only want to show the next three items starting from now(). Here is my controller function:

Probably the whole thing is completely wrong, but still, any help will be greatly appreciated.

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

    }



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2oN6pUz
via IFTTT

Aucun commentaire:

Enregistrer un commentaire