protected function addTimeConstraints($request, $query)
    {
        if ($request->query('from')) {
            $from = new \DateTime($request->query('from'));
            $until = new \DateTime();
        }

        if ($request->query('until')) {
            $until = new \DateTime($request->query('until'));
        }

        if (!empty($from)) {
            $query->where(function ($builder) use ($from, $until) {
                return $builder->between('@timestamp', $from->format('Y-m-d H:i:s'), $until->format('Y-m-d H:i:s'));
            });
            return;
        }

        if (!empty($until)) {
            $query->where(['@timestamp <=' => $until->format('Y-m-d H:i:s')]);
        }
    }
protected function addTimeConstraints($request, $query)
    {
        if ($request->query('from')) {
            $from = new \DateTime($request->query('from'));
            $until = new \DateTime();
        }

        if ($request->query('until')) {
            $until = new \DateTime($request->query('until'));
        }

        if (!empty($from)) {
            $query->where(function ($builder) use ($from, $until) {
                return $builder->between('@timestamp', $from->format('Y-m-d H:i:s'), $until->format('Y-m-d H:i:s'));
            });
            return;
        }

        if (!empty($until)) {
            $query->where(['@timestamp <=' => $until->format('Y-m-d H:i:s')]);
        }
    }
protected function addTimeConstraints ( $ request , $ query ) { if ( $ request -> query ( 'from' ) ) { $ from = new \ DateTime ( $ request -> query ( 'from' ) ) ; $ until = new \ DateTime ( ) ; } if ( $ request -> query ( 'until' ) ) { $ until = new \ DateTime ( $ request -> query ( 'until' ) ) ; } if ( ! empty ( $ from ) ) { $ query -> where ( function ( $ builder ) use ( $ from , $ until ) { return $ builder -> between ( '@timestamp' , $ from -> format ( 'Y-m-d H:i:s' ) , $ until -> format ( 'Y-m-d H:i:s' ) ) ; } ) ; return ; } if ( ! empty ( $ until ) ) { $ query -> where ( [ '@timestamp <=' => $ until -> format ( 'Y-m-d H:i:s' ) ] ) ; } }
Alters the query object to add the time constraints as they can be found in
the request object.

@param Cake\Network\Request $request The request where query string params can be found
@param Cake\ElasticSearch\Query $query The Query to add filters to
@return void
Alters the query object to add the time constraints as they can be found in the request object .