Fix when date is not speicifed in warranty:sms command #394

This commit is contained in:
Kendrick Chan 2020-05-04 11:34:34 +08:00
parent e8446cd181
commit 1a78320ca9

View file

@ -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]);