media->listFolderContents($folder) as $item) { if ($item->type === 'folder') { $this->resize($item->path); } else { Queue::push(ResizeJob::class, [$item->path, 'update' => $this->option('update', false)], Setting::get('queue')); } } } /** * Execute the console command. * @return void */ public function handle(CacheManager $cacheManager) { $this->media = MediaLibrary::instance(); ProgressBar::setFormatDefinition('custom', '%current%/%max% %bar% -- %message% (%size%)'); if ($this->option('folder')) { throw_unless(in_array($this->option('folder'), array_column(Setting::get('folders'), 'folder')), Exception::class, 'Folder not found'); if (!$this->option('update')) { Storage::deleteDirectory('uploads/public/c'.$this->option('folder')); } $this->resize($this->option('folder')); return; } if (!$this->option('update')) { Storage::deleteDirectory('uploads/public/c'); } $cacheManager->flush(); foreach (Setting::get('folders') as $folder) { $this->resize($folder['folder']); } } /** * Get the console command arguments. * @return array */ protected function getArguments() { return [ ]; } /** * Get the console command options. * @return array */ protected function getOptions() { return [ ['folder', 'f', InputOption::VALUE_OPTIONAL, 'Just resize for specific subfolders', null], ['update', 'u', InputOption::VALUE_NONE, 'Just update missing files', null], ]; } }