diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 1ce49fb..9d2a908 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -7,6 +7,7 @@ use App\Domains\Migration\Commands\AttachImagesCommand; use App\Domains\Migration\Commands\AttachImagesToTagsCommand; use App\Domains\Migration\Commands\CopyWpFilesCommand; +use App\Domains\Migration\Commands\FixFilesCommand; use App\Domains\Migration\Commands\FixLinksInDescription; use App\Domains\Migration\Commands\MaterialsMergerCommand; use App\Domains\Migration\Commands\MergeAccountDuplicatesCommand; @@ -43,6 +44,7 @@ class Kernel extends ConsoleKernel MaterialsMergerCommand::class, MergeAccountDuplicatesCommand::class, ReattachAttachmentsCommand::class, + FixFilesCommand::class, ]; protected function schedule(Schedule $schedule): void diff --git a/app/Domains/Migration/Commands/FixFilesCommand.php b/app/Domains/Migration/Commands/FixFilesCommand.php new file mode 100644 index 0000000..a533366 --- /dev/null +++ b/app/Domains/Migration/Commands/FixFilesCommand.php @@ -0,0 +1,33 @@ +argument('wpid')); + + $material = Material::where('wp_id', $post->ID)->first(); + $this->attachFiles($post, $material); + + // /** @var Attachment $attachment */ + // foreach ($post->attachments as $attachment) { + // } + } + + protected function generateName(Post $post, Attachment $attachment): string + { + $extension = pathinfo($attachment->guid, PATHINFO_EXTENSION); + + return "post{$post->ID}_file{$attachment->ID}.{$extension}"; + } +}