Dosmukhanbet
2 months ago
457
14
Eloquent

Query model when column not null

Posted 2 months ago by Dosmukhanbet

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

Please sign in or create an account to participate in this conversation.