Actually, I have the solution, but I want to know if there is a more efficient solution. What I need are the events that have not yet expired so to speak. Within a base with all the events.
Basically what I do is get the events with an OrderBy from the ascending date and then I go through, comparing with the current one, taking the minor ones. And staying with those that exceed the current date.
I wanted to know if in any way, from a controller or a composer, I can already get the list with the date I need from the beginning, without using the foreach. It would be neat, or efficient too, somehow put a query to the database here
public function compose(View $view)
{
$categorias= Categoria::orderBy('nombre','asc')->get();
$tags= Tag::orderBy('nombre','asc')->get();
$eventos= Evento::orderBy('fecha','asc')->get();
foreach ($eventos as $key => $evento) {
if ($evento->fecha <= Carbon::now()) {
unset($eventos[$key]);
}
}
$view
->with('categorias', $categorias)
->with('eventos',$eventos)
->with('tags',$tags);
}