getLastDays example



    public function handle(ConditionInterface $condition, QueryBuilder $query)
    {
        $this->addCondition($condition$query);
    }

    private function addCondition(OrderedInLastDaysCondition $condition, QueryBuilder $query): void
    {
        $query->andWhere('customer.last_order_time >= :OrderedInLastDaysCondition');
        $date = new DateTime();
        $date->sub(new DateInterval('P' . $condition->getLastDays() . 'D'));
        $query->setParameter(':OrderedInLastDaysCondition', $date->format('Y-m-d H:i:s'));
    }
}


    public function handle(ConditionInterface $condition, QueryBuilder $query): void
    {
        $this->addCondition($condition$query);
    }

    private function addCondition(NotOrderedInLastDaysCondition $condition, QueryBuilder $query): void
    {
        $query->andWhere('customer.last_order_time <= :NotOrderedInLastDaysCondition');
        $date = new DateTime();
        $date->sub(new DateInterval('P' . $condition->getLastDays() . 'D'));
        $query->setParameter(':NotOrderedInLastDaysCondition', $date->format('Y-m-d H:i:s'));
    }
}
Home | Imprint | This part of the site doesn't use cookies.