Get the changes attributes

@param  Model  $model  The model being touched
@param  string $action
@return array|null
191468
static private function getChanged(Model $model, $action)
    {
        $changed = $model->getDirty();
        if ($action == 'deleted' || empty($changed)) {
            $changed = null;
        }
        return $changed;
    }
682056
protected function performUpdate(Model $model)
    {
        $data = collect([$this->getIndexColumn($model) => $this->toVector($model)]);

        $query = $this->database
            ->table($model->searchableAs())
            ->where($model->getKeyName(), '=', $model->getKey());

        if (method_exists($model, 'searchableAdditionalArray')) {
            $data = $data->merge($model->searchableAdditionalArray() ?: []);
        }

        if (! $this->isExternalIndex($model) || $query->exists()) {
            return $query->update($data->all());
        }

        return $query->insert(
            $data->merge([
                $model->getKeyName() => $model->getKey(),
            ])->all()
        );
    }
597717
public function getModelsToUpdate()
    {
        return $this->models->filter(function (AbstractModel $model) {
            return ($model->isChanged() and ($model->isSaved() or $model->isSoftDeleted()));
        });
    }
756488
protected function getAutomaticallyUpdatedFields($entity, $action)
    {
        $updateFields = [];

        // auto increment
        if ($action == 'insert' && $this->incrementing) {
            $updateFields[] = $this->getKeyName();
        }

        // auto uuid
        if ($action == 'insert' && method_exists($this, 'bootAutoUuid')) {
            $updateFields = array_merge($this->autoUuids, $updateFields);
        }

        // timestamps
        if ($this->timestamps) {
            if ($action == 'insert') {
                $updateFields[] = $this->getCreatedAtColumn();
            }
            $updateFields[] = $this->getUpdatedAtColumn();
        }
        
        // soft deletes
        if ($action == 'update' && method_exists($this, 'bootSoftDeletes')) {
            $updateFields[] = $this->getDeletedAtColumn();
        }

        return $updateFields;
    }
87027
public function getAttributes($model)
    {
        $this->model = $model;
        $this->attributes = self::buildRelationshipAttributes($this->model);
        $this->attributes = $this->attributes + self::buildAttributes($this->model);

        return $this->attributes;
    }
1268555
protected function getLinkForReferenceModel(Model $model)
    {
        $routeName = $this->getRouteHelper()->getRouteNameForModelClass(get_class($model), true);

        $action = $this->determineRouteAction($model);

        return route($routeName . '.' . $action, $model->getKey());
    }
336901
protected function getCasts(Model $model)
    {
        $class = get_class($model);

        if (!isset($this->castsCache[$class])) {
            $this->castsCache[$class] = Cheat::get($model, 'casts');
        }

        return $this->castsCache[$class];
    }
837218
protected function getEditButtons(Action $action, EnvironmentInterface $environment)
    {
        $translator = $environment->getTranslator();

        $mode = $this->getMode($action);

        $buttons = [];

        $buttons['save'] = \sprintf(
            '<input type="submit" name="%s_save" id="%s_save" class="tl_submit" accesskey="s" value="%s" />',
            $mode,
            $mode,
            $translator->translate('MSC.save')
        );

        $buttons['save'] .= '&nbsp;';

        $buttons['save'] .= \sprintf(
            '<input type="submit" name="%s_saveNback" id="%s_saveNback" class="tl_submit" accesskey="c" value="%s" />',
            $mode,
            $mode,
            $translator->translate('MSC.saveNback')
        );

        $submitButtonTemplate = new ContaoBackendViewTemplate('dc_general_submit_button');
        $submitButtonTemplate->setData($buttons);

        return \preg_replace('/(\s\s+|\t|\n)/', '', $submitButtonTemplate->parse());
    }
1353987
protected function replaceExistingModel($model, $attribute)
    {
        $modelAttributes = $model->attributes;
        unset($modelAttributes[$model->primaryKey()[0]]);

        foreach ($this->relationalData[$attribute]['oldModels'] as $oldModel) {
            /** @var ActiveRecord $oldModel */
            $oldModelAttributes = $oldModel->attributes;
            unset($oldModelAttributes[$oldModel->primaryKey()[0]]);

            if ($oldModelAttributes == $modelAttributes) {
                return $oldModel;
            }
        }

        return $model;
    }
660820
public function calculateChangeSet()
    {
        if (false === $this->isDirty()) {
            return [];
        }
        return [
            'old' => empty($this->original) ? null : $this->original,
            'new' => empty($this->models) ? null : $this->models,
        ];
    }
1356157
private function getOperation(Action $action, EnvironmentInterface $environment)
    {
        /** @var Contao2BackendViewDefinitionInterface $definition */
        $definition = $environment->getDataDefinition()->getDefinition(Contao2BackendViewDefinitionInterface::NAME);
        $name       = $action->getName();
        $commands   = $definition->getModelCommands();

        if (!$commands->hasCommandNamed($name)) {
            return null;
        }

        return $commands->getCommandNamed($name);
    }
810653
public function getSetupMethod($action)
    {
        if ($this->reflection->hasMethod('setup'.ucwords($action))) {
            return $this->reflection->getMethod('setup'.ucwords($action));

        } elseif ($this->reflection->hasMethod('setup')) {
            return $this->reflection->getMethod('setup');
        }

        return null;
    }
166123
public function getTemplatesFor($action)
    {
        $templates = SSViewer::get_templates_by_class(static::class, "_{$action}", __CLASS__);

        return array_merge(
            $templates,
            [
                "Security_{$action}",
                "Security",
                $this->config()->get("template_main"),
                "BlankPage"
            ]
        );
    }
1043047
public function getRoundModel($detailed, $action)
    {
        $model = parent::getRoundModel($detailed, $action);

        $model->set('gro_valid_for_id',
                'default', '0');

        return $model;
    }
348139
public function can($action, Model $model)
    {
        if (! $this->checkAccess) {
            return true;
        }

        return \Gate::allows($action, [$this, $model]);
    }
7292
private function getMutableAttributes($model)
    {
        $attrs = get_object_vars($model);
        unset($attrs[$this->key]);
        
        // remove reference attributes, if any
        if ($model instanceof ManagedModelInterface) {
            foreach (array_keys($model->getReferences()) as $ref) {
                unset($attrs[$ref]);
            }
        }
        
        return $attrs;
    }
650856
public function models($action = null)
    {
        $settings = $this->relatedModels(null, $action);

        if ($settings === true) {
            return $this->getAssociatedByType(['oneToOne', 'manyToMany', 'manyToOne']);
        }

        if (empty($settings)) {
            return [];
        }

        if (is_string($settings)) {
            $settings = [$settings];
        }

        return $this->getAssociatedByName($settings);
    }