From: Louis Jeckel Date: Sun, 16 Aug 2020 16:26:31 +0000 (+0200) Subject: Update IngestPdfFiles.php X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=1d4f73fface449205e2ec9ae9423c5ffdc7f104f;p=psq.git Update IngestPdfFiles.php --- diff --git a/app/Console/Commands/IngestPdfFiles.php b/app/Console/Commands/IngestPdfFiles.php index 1377f14..e56777f 100644 --- a/app/Console/Commands/IngestPdfFiles.php +++ b/app/Console/Commands/IngestPdfFiles.php @@ -16,7 +16,7 @@ class IngestPdfFiles extends Command * * @var string */ - protected $signature = 'pdf:ingest'; + protected $signature = 'pdf:ingest {mode=auto}'; /** * The console command description. @@ -48,11 +48,22 @@ class IngestPdfFiles extends Command foreach ($files as $file) { $path = \Storage::path($file); - $fileName = basename($path, '.pdf'); - $ref = Str::after($fileName, 'PSQ '); - $lastModified = \File::lastModified($path); - $lastModified = Carbon::createFromFormat("U", $lastModified); + + + if($this->argument('mode') === 'fileName'){ + $fileName = basename($path, '.pdf'); + $ref = Str::after($fileName, 'PSQ '); + $date = \File::lastModified($path); + $date = Carbon::createFromFormat("U", $date); + + } else { + $fileName = basename($path, '.pdf'); + $ref = Str::after($fileName, 'PSQ '); + $date = \File::lastModified($path); + $date = Carbon::createFromFormat("U", $date); + } + $collection = FileCollection::findOrFail(1); $title = "{$collection->short_name} - $ref"; @@ -70,7 +81,7 @@ class IngestPdfFiles extends Command 'title' => $title, 'headlines' => [], 'published' => 1, - 'created_at' => $lastModified + 'created_at' => $date ]); $this->info("$pdfFile created. Processing file.");