Reputation: 315
I'm using Laravel 5.4, and I need to check both event and created date conditions at once. So I used following code.
protected $table = 'qlog';
public $timestamps = false;
public function getAbondonedCalls()
{
$results = DB::table('qlog')
->whereDate('created', '=', DB::raw('curdate()'))
->where('event', '=', 'ABANDON')
->get();
var_dump($results);
die();
}
But this code returns nothing. After removing this line it returns a record.
->whereDate('created', '=', DB::raw('curdate()'))
How to add both conditions?
Upvotes: 6
Views: 53320
Reputation: 85
For convenience, if you want to verify that a column is equal to a given value, you may pass the value directly as the second argument to the whereDate method: i.e. without including '=' sign
->whereDate('created', date('Y-m-d'))
Upvotes: 2
Reputation: 21681
You should try this:
->whereDate('created', '=', date('Y-m-d'))
Upvotes: 24