Used maxVisits field when creating or fetching a ShortUrl

This commit is contained in:
Alejandro Celaya
2017-10-22 09:15:37 +02:00
parent af7c11665c
commit cb23d38b38
6 changed files with 21 additions and 8 deletions

View File

@@ -65,6 +65,9 @@ class GenerateShortcodeCommand extends Command
))
->addOption('customSlug', 'c', InputOption::VALUE_REQUIRED, $this->translator->translate(
'If provided, this slug will be used instead of generating a short code'
))
->addOption('maxVisits', 'm', InputOption::VALUE_REQUIRED, $this->translator->translate(
'This will limit the number of visits for this short URL.'
));
}
@@ -99,6 +102,7 @@ class GenerateShortcodeCommand extends Command
}
$tags = $processedTags;
$customSlug = $input->getOption('customSlug');
$maxVisits = $input->getOption('maxVisits');
try {
if (! isset($longUrl)) {
@@ -111,7 +115,8 @@ class GenerateShortcodeCommand extends Command
$tags,
$this->getOptionalDate($input, 'validSince'),
$this->getOptionalDate($input, 'validUntil'),
$customSlug
$customSlug,
$maxVisits !== null ? (int) $maxVisits : null
);
$shortUrl = (new Uri())->withPath($shortCode)
->withScheme($this->domainConfig['schema'])