From a3bd5da226cd1195802f123cb5da5efb07ad6a0f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 30 Jan 2020 00:21:01 -0700 Subject: [PATCH] Add MediaFix command --- app/Console/Commands/MediaFix.php | 61 +++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 app/Console/Commands/MediaFix.php diff --git a/app/Console/Commands/MediaFix.php b/app/Console/Commands/MediaFix.php new file mode 100644 index 000000000..abed6f79e --- /dev/null +++ b/app/Console/Commands/MediaFix.php @@ -0,0 +1,61 @@ +error('Please update to version 0.10.8 or newer.'); + exit; + } + + $classes = Filter::classes(); + + Media::whereNotNull('filter_class') + ->chunk(50, function($filters) use($classes) { + foreach($filters as $filter) { + $match = $filter->filter_class ? in_array($filter->filter_class, $classes) : true; + if(!$match) { + $filter->filter_class = null; + $filter->filter_name = null; + $filter->save(); + } + } + }); + } +}