From 1a78320ca9af7544a922d7785cfd370e9e07b978 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Mon, 4 May 2020 11:34:34 +0800 Subject: [PATCH] Fix when date is not speicifed in warranty:sms command #394 --- src/Command/WarrantySMSCommand.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Command/WarrantySMSCommand.php b/src/Command/WarrantySMSCommand.php index 24ae7542..dfacab65 100644 --- a/src/Command/WarrantySMSCommand.php +++ b/src/Command/WarrantySMSCommand.php @@ -37,14 +37,16 @@ class WarrantySMSCommand extends Command protected function execute(InputInterface $input, OutputInterface $output) { - $date = new DateTime(); $date_string = $input->getArgument('date'); + // if date is specified if (!empty($date_string)) - { $date = DateTime::createFromFormat('Ymd', $date_string); - $date->modify('-1 month'); - } + else + $date = new DateTime(); + + // -1 month + $date->modify('-1 month'); $warrs = $this->em->getRepository(Warranty::class)->findBy(['date_expire' => $date]);