public function scopeOlderThanOrBetween(Builder $query, $until = null, $from = null)
    {
        if (is_null($until))
        {
            $until = Carbon::now();
        }

        $query->where('created_at', '<', $until);

        if ( ! is_null($from))
        {
            $query->where('created_at', '>=', $from);
        }

        return $query;
    }
public function scopeOlderThanOrBetween(Builder $query, $until = null, $from = null)
    {
        if (is_null($until))
        {
            $until = Carbon::now();
        }

        $query->where('created_at', '<', $until);

        if ( ! is_null($from))
        {
            $query->where('created_at', '>=', $from);
        }

        return $query;
    }
public function scopeOlderThanOrBetween ( Builder $ query , $ until = null , $ from = null ) { if ( is_null ( $ until ) ) { $ until = Carbon :: now ( ) ; } $ query -> where ( 'created_at' , '<' , $ until ) ; if ( ! is_null ( $ from ) ) { $ query -> where ( 'created_at' , '>=' , $ from ) ; } return $ query ; }
Scope for choosing by date

@param Builder $query
@param timestamp $until
@param timestamp|null $from
@return Builder
Scope for choosing by date