]> _ Git - psq.git/commitdiff
Update IngestPdfFiles.php
authorLouis Jeckel <louis.jeckel@outlook.cm>
Sun, 16 Aug 2020 16:26:31 +0000 (18:26 +0200)
committerLouis Jeckel <louis.jeckel@outlook.cm>
Sun, 16 Aug 2020 16:26:31 +0000 (18:26 +0200)
app/Console/Commands/IngestPdfFiles.php

index 1377f14c8c471fb56c9b6bc44129dd6e975a2e2b..e56777faa6efc456dea4a69b352d0fd8d4baabdf 100644 (file)
@@ -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.");