Support the ongoing development of Laravel.io →
Database Eloquent Views
Last updated 2 years ago.
0

why dont u add a where?

Event::Where('event_date' < today() )->get();
Last updated 2 years ago.
0

extjac said:

why dont u add a where?

Event::Where('event_date' < today() )->get();

My EventController.php looks

	public function index()
	{
		$events = Event::where('datetimefrom' < today() )->get();
		$events = Event::orderBy('datetimefrom', 'asc')->get();				
      
		return View::make('events.index', array(
			'events' => $events
			));	
    }

When I paste this code

$events = Event::where('datetimefrom' < today() )->get();

I get following error

Call to undefined function today()

I also tryed to put this in my Event.php model

public function today()
	{
		$date = new Date('now');
		return $date;
	}

and still the same message :(

Last updated 2 years ago.
0
Event::where('event_date', '<', new Date('now'))->get();
Last updated 2 years ago.
0

Yes, it worked!! :)) Thanks!

But How I can also pass orderBy date to my view?

$procedures = Procedure::orderBy('datetimefrom', 'asc')->get();	

EventController.php

public function index()
	{		
		$events = Event::orderBy('datetimefrom', 'asc')->get();	
		$events = Event::where('datetimefrom', '>', new Date('now'))->get();
			
			
        // and create a view which we return - note dot syntax to go into folder        
		return View::make('events.index', array(
			'events' => $events
			));	
    }
Last updated 2 years ago.
0
 $events = Event::where('datetimefrom', '>', new Date('now'))->orderBy('id', 'DESC')->get();


Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

LOGINGRUPA logingrupa Joined 24 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.