/** * Clean up abandoned fields. */ public function cleanup() { $fieldTypes = app('field_type.collection')->lists('namespace'); $this->model->leftJoin('streams_streams', 'streams_fields.namespace', '=', 'streams_streams.namespace')->whereNull('streams_streams.id')->delete(); $this->model->where('slug', '')->delete(); $this->model->where('namespace', '')->delete(); $this->model->whereNotIn('type', $fieldTypes)->delete(); $translations = $this->model->getTranslationModel(); $translations->leftJoin('streams_fields', 'streams_fields_translations.field_id', '=', 'streams_fields.id')->whereNull('streams_fields.id')->delete(); }