Look at whereNotNull.
Aug 11, 2020
14
Level 28
Query model when column not null
hello, Please could somebody help. I have date_to column, it can be null and I wanna add where query when this column not null but following code does not work
$this->trips()->where( function ( $query ) use ( $date ) {
$query->whereNull( 'date_to' )
->orWhere('date_to', '<=' , Carbon::parse($date)->format('Y-m-d'));
});
Level 75
$this->trips()->whereNotNull('date_to')->where('date_to', '<=', Carbon::parse($date)->toDateString())->get();
Please or to participate in this conversation.