Delete translations when model is deleted.

@param  Model $model
@return void
481478
public function deleted($model)
    {
        $translationRepository = \App::make(TranslationRepository::class);
        foreach ($model->translatableAttributes() as $attribute) {
            $translationRepository->deleteByCode($model->translationCodeFor($attribute));
        }
    }
1268144
public function saved($model)
    {
        if (static::syncingDisabledFor($model)) {
            return;
        }

        if (! $model->shouldBeSearchable()) {
            $model->unsearchable();

            return;
        }

        $model->searchable();
    }
403650
private function deleteOneToManyRelations(\Tx_Oelib_Model $model)
    {
        $data = $model->getData();

        foreach ($this->relations as $key => $mapperName) {
            if ($this->isOneToManyRelationConfigured($key)) {
                $relatedModels = $data[$key];
                if (!is_object($relatedModels)) {
                    continue;
                }

                $mapper = \Tx_Oelib_MapperRegistry::get($mapperName);
                /** @var \Tx_Oelib_Model $relatedModel */
                foreach ($relatedModels as $relatedModel) {
                    $mapper->delete($relatedModel);
                }
            }
        }
    }
276100
public function deleted(Model $model)
    {
        try {
            Croppa::delete('storage/'.$model->getOriginal('path'));
        } catch (Exception $e) {
            Log::error($e->getMessage());
        }
    }
1042697
public function updateDeleteBlameable(Model $model)
    {
        $user = $this->getActiveUser();

        if (is_null($user)) {
            return;
        }

        // Set deleted-at if it has not been touched
        if ($this->isBlameable($model, 'deleted') && !$model->isDirty($this->getColumn($model, 'deleted'))) {
            $this->setDeletedBy($model, $user);
            $model->save();
        }

    }
126504
public function deleteTranslations($locales = null)
    {
        if ($locales === null) {
            $translations = $this->translations()->get();
        } else {
            $locales = (array) $locales;
            $translations = $this->translations()->whereIn($this->getLocaleKey(), $locales)->get();
        }
        foreach ($translations as $translation) {
            $translation->delete();
        }
        // we need to manually "reload" the collection built from the relationship
        // otherwise $this->translations()->get() would NOT be the same as $this->translations
        $this->load('translations');
    }
1063977
def delete_translations(sender, instance, **kwargs):
    
    if issubclass(sender, (ModelMixin,)):
        instance._linguist.decider.objects.filter(
            identifier=instance.linguist_identifier, object_id=instance.pk
        ).delete()
700689
public function setBelongsToData(Model $model) {
        $typeAhead = array();

        foreach ($model->belongsTo as $alias => $assoc) {
            $object = Admin::introspectModel($assoc['className']);
            $count = $this->getRecordCount($object);

            // Add to type ahead if too many records
            if (!$count || $count > $object->admin['associationLimit']) {
                $class = $assoc['className'];

                if (mb_strpos($class, '.') === false) {
                    $class = Configure::read('Admin.coreName') . '.' . $class;
                }

                // Get the foreign key from the child -> parent
                $foreignKey = null;

                foreach ($object->belongsTo as $childAssoc) {
                    if ($childAssoc['className'] === $model->name) {
                        $foreignKey = $childAssoc['foreignKey'];
                        break;
                    }
                }

                $typeAhead[$assoc['foreignKey']] = array(
                    'alias' => $alias,
                    'model' => $class,
                    'foreignKey' => $foreignKey
                );

            } else {
                $variable = Inflector::variable(Inflector::pluralize(preg_replace('/(?:_id)$/', '', $assoc['foreignKey'])));

                $this->Controller->set($variable, $this->getRecordList($object));
            }
        }

        $this->Controller->set('typeAhead', $typeAhead);
    }
1132842
protected function _cleanupOldFiles(Model $model, array $fields) {
        $columns = $this->_columns[$model->alias];
        $data = $this->_doFind($model, array($model->alias . '.' . $model->primaryKey => $model->id));

        if (empty($data[$model->alias])) {
            return;
        }

        foreach ($fields as $column => $value) {
            if (empty($data[$model->alias][$column])) {
                continue;
            }

            if (!empty($this->settings[$model->alias][$columns[$column]])) {
                $attachment = $this->_settingsCallback($model, $this->settings[$model->alias][$columns[$column]]);

                if (!$attachment['cleanup']) {
                    continue;
                }
            }

            // Delete if previous value doesn't match new value
            $previous = $data[$model->alias][$column];

            if ($previous !== $value) {
                $this->_deleteFile($model, $columns[$column], $previous, $column);
            }
        }
    }
877596
def on_delete_model_translation(instance, **kwargs):
    
    translation = instance

    parent_object = translation.master
    parent_object.set_current_language(translation.language_code)

    # Also delete any associated plugins
    # Placeholders are shared between languages, so these are not affected.
    for item in ContentItem.objects.parent(parent_object, limit_parent_language=True):
        item.delete()
666932
private function doCommitDelete(Model $model)
    {
        $this->dispatchLifecycleEvent(Events::preDelete, $model);

        $this->getPersisterFor($model->getType())->delete($model);
        $model->getState()->setDeleted();

        $this->dispatchLifecycleEvent(Events::postDelete, $model);
        return $model;
    }
1259362
public function updateFromModel(ModelTranslation $translation)
    {
        $this->setLocale($translation->getLocale());
        $this->setValue($translation->getValue());
        $this->setMetadata($translation->getMetadata());
    }
750989
public function remove($model)
    {
        $class    = $this->manager->getClassMetadata(get_class($model));
        $managers = $class->getFieldManagerNames();
        $priority = $this->manager->getPool()->getPriority('transaction');

        foreach ($managers as $key => $managerName) {
            if (isset($priority[$managerName])) {
                $this->manager->remove($model);

                unset($managers[$key]); // dereference index
            }
        }

        foreach ($managers as $managerName) {
            $this->addQueue(self::QUEUE_ACTION_REMOVE, $managerName, $model);
        }
    }
691738
public function deleting($model)
    {
        if ($model->accountableEnabled() &&
            collect(class_uses($model))->contains(SoftDeletes::class)) {
            $model->{$this->config['column_names']['deleted_by']} = $this->accountableUserId();

            $model->save();
        }
    }
1116622
public function destroy(Model $model)
    {
        $this->mention->where('model_type', get_class($this->model))
            ->where('model_id', $this->model->getKey())
            ->where('recipient_type', get_class($model))
            ->where('recipient_id', $model->getKey())
            ->delete();
    }
1227504
public function deleteModels(Models $models)
    {
        foreach ($models as $model) {
            $this->dispatchBeforeEvent($model, Event::DELETE);
        }

        $this->deleteAll()->executeModels($models);

        foreach ($models as $model) {
            $this->dispatchAfterEvent($model, Event::DELETE);
        }

        return $this;
    }
187236
protected function runSerializeTransformsOnModel(Model $model)
    {
        // Loop through all the transform functions
        foreach ($this->serialize_transforms as $transform) {

            // Call the transform and if nothing is retuned, return nothing. This will
            // be used by runSerializeTransformsOnCollection() to filter out models.
            if (!$model = call_user_func($transform, $model)) {
                return;
            }
        }

        // Return the transformed model
        return $model;
    }