public function fire() { $onlyForModel = ucfirst($this->argument('model')); foreach (Media::all() as $media) { if ($onlyForModel == '' || $onlyForModel == $media->content_type) { MediaLibrary::regenerateDerivedFiles($media); $this->info('Media id ' . $media->id . ' "' . $media->path . '" reprocessed' . ' (for ' . $media->content_type . ' id ' . $media->content_id . ')'); } } $this->info('All done!'); }
/** * Remove all media in the given collection. * * @param $collectionName * @return void */ public function removeMediaCollection($collectionName) { $media = $this->getMedia($collectionName); foreach ($media as $mediaItem) { MediaLibrary::remove($mediaItem->id); } }