where('passwordstatus', '<=', -2)->get(); foreach ($badReleases as $badRelease) { $nzbPath = (new NZB)->getNZBPath($badRelease->guid); File::delete($nzbPath); (new ReleaseImage)->delete($badRelease->guid); if (config('nntmux.elasticsearch_enabled') === true) { $params = [ 'index' => 'releases', 'id' => $badRelease->id, ]; try { Elasticsearch::delete($params); } catch (Missing404Exception $e) { // we do nothing here just catch the error, we don't care if release is missing from ES, we are deleting it anyway } } else { $identifiers = [ 'i' => $badRelease->id, ]; // Delete from sphinx. (new ManticoreSearch)->deleteRelease($identifiers); } $badRelease->delete(); } Release::query()->where('passwordstatus', '=', -2)->delete(); $passReleases = ReleaseFile::query()->where('passworded', '=', 1)->groupBy('releases_id')->get(); $count = 0; foreach ($passReleases as $passRelease) { Release::whereId($passRelease->releases_id)->update(['passwordstatus' => 1]); $count++; } $this->info('Updated '.$count.' bad releases'); } }