How to filter between two date only if they are not empty or null
Hello , I am trying to make filter.I am trying to filter between two date only if they are not null or empty.In my case if $from and $to variable are empty it is filtering with today date.So how to make filter only if $from and to and are not empty ?
$from = "2020-12-01" ?? ''; // date coming from filter
$to = "2020-12-27" ?? ''; // date coming filter
$order=Order::where('status','delivered')
->where('delivery_date','>=' ,Carbon::parse($from))
->where('delivery_date','<=' ,Carbon::parse($to))
->get();