app\Order::scopeOfDates PHP Method

scopeOfDates() public method

public scopeOfDates ( $query, $from, $to = '' )
    public function scopeOfDates($query, $from, $to = '')
    {
        if (trim($from) == '' && trim($to) == '') {
            return;
        }
        if (trim($from) != '' && trim($to) != '') {
            return $query->whereBetween(\DB::raw('DATE(orders.created_at)'), [$from, $to]);
        } elseif (trim($from) != '' && trim($to) == '') {
            return $query->where(\DB::raw('DATE(orders.created_at)'), $from);
        } elseif (trim($from) == '' && trim($to) != '') {
            return $query->where(\DB::raw('DATE(orders.created_at)'), $to);
        }
    }