@param Model $model

@since  1.1.0

@author Eddilbert Macharia (http://eddmash.com) <edd.cowan@gmail.com>

@throws ImproperlyConfigured
974888
public function prepare(Model $model)
    {
        if (empty($this->primaryKey)) {
            if (!empty($this->parents)) {
                $field = $this->parents;
                $field->primaryKey = true;
                $this->setupPrimaryKey($field);
                if (!$field->relation->parentLink) {
                    throw new ImproperlyConfigured(
                        sprintf('Add parentLink=True to %s.', $field)
                    );
                }
            } else {
                $field = AutoField::createObject(
                    [
                        'verboseName' => 'ID',
                        'primaryKey' => true,
                        'autoCreated' => true,
                    ]
                );

                $model->addToClass('id', $field);
            }
        }
    }
1122662
public function delete($model)
    {
        $this->db->connect()
            ->deleteFrom($this->table)
            ->where($this->key . ' = ?')
            ->execute([$model->{$this->key}]);
        $model->{$this->key} = null;
    }
226775
public function setModel(Model $model)
    {
        parent::setModel($model);
        $this->setHtmlAttribute('data-value', $this->getModelValue());

        return $this;
    }
359988
public function afterDelete(Model $Model) {
		if ($this->settings[$Model->alias]['auto'] === false) {
			return;
		}
		if (!$Model->ShadowModel) {
			return;
		}
		if (isset($this->deleteUpdates[$Model->alias]) && !empty($this->deleteUpdates[$Model->alias])) {
			foreach ($this->deleteUpdates[$Model->alias] as $assocAlias => $assocIds) {
				$Model->{$assocAlias}->updateRevisions($assocIds);
			}
			unset($this->deleteUpdates[$Model->alias]);
		}
	}
692955
public function setup(Model $Model, $config = array()) {
		$defaults = (array)Configure::read('Revision') + $this->_defaultConfig;
		$this->settings[$Model->alias] = $config + $defaults;

		$this->_createShadowModel($Model);
		if (!$Model->Behaviors->loaded('Containable')) {
			$Model->Behaviors->load('Containable');
		}
	}
579147
public function deleting(Model $model)
    {
        $model->deleted_by = $this->guard->check() ? $this->guard->user()->getId() : null;
    }
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();
    }
1275661
public function setup(Model $Model, $config = array()) {
		if (is_string($config)) {
			$config = array($config);
		}

		$_config = array();

		foreach ((array) $config as $field => $options) {
			if (is_int($field) && is_string($options)) {
				$field = $options;
				$options = $this->_options;
			}
			$_config[$field] = array_merge($this->_options, $options);
		}

		$this->settings[$Model->alias] = $_config;
	}
848554
public function saved(Model $model)
    {
        $tags = $this->processTags(request('tags'));
        $this->syncTags($model, $tags);
    }
409573
public function setup(Model $model, $settings = array()) {
        $this->settings[$model->alias] = Hash::merge($this->_defaults, $settings);
    }
922982
public function setModel($model)
    {
        $this->model = get_class($model);
        $this->modelId = $model->id;
        
        return $this;
    }
556735
public function setModel(Model $model)
    {
        parent::setModel($model);

        if ($model->exists) {
            $this->setInstance($model);
            $this->loadRelationValues();
        }
    }
333940
public function setModel($model)
    {
        /** @type Model $model */
        $model = parent::setModel($model);

        foreach ($model as $rule) {
            $this->addRule($rule['rule'], $rule['target'], explode(',', $rule['params']));
        }

        // @todo Consider to return $model instead of $this like we do in setModel method of all other classes
        return $this;
    }
681889
protected function loadRelatedModels(Model $model) {
        // get the relations to load
        $relations = $this->exposedRelationsFromRequest($model);

        foreach ($relations as $relation) {
            // if this relation is loaded via a method, then call said method
            if (in_array($relation, $model->relationsFromMethod())) {
                $model->$relation = $model->$relation();
                continue;
            }

            $model->load($relation);
        }
    }
4173
public function setup(Model $model, $settings = array()) {
		$default = array(
			'fields' => 'title',
			'scope' => false,
			'conditions' => false,
			'slugfield' => 'slug',
			'separator' => '-',
			'overwrite' => false,
			'length' => 256,
			'lower' => true
		);

		$this->__settings[$model->alias] = (!empty($settings)) ? $settings + $default : $default;
	}
356379
public function setModel(\atk4\data\Model $model)
    {
        parent::setModel($model);
        $this->field = $this->field ? $this->field : $this->model->title_field;
        if ($this->autoSave && $this->model->loaded()) {
            if ($this->cb->triggered()) {
                $value = $_POST['value'] ? $_POST['value'] : null;
                $this->cb->set(function () use ($value) {
                    try {
                        $this->model[$this->field] = $this->app->ui_persistence->typecastLoadField($this->model->getElement($this->field), $value);
                        $this->model->save();

                        return $this->jsSuccess('Update successfully');
                    } catch (ValidationException $e) {
                        $this->app->terminate(json_encode([
                              'success'            => true,
                              'hasValidationError' => true,
                              'atkjs'              => $this->jsError(call_user_func($this->formatErrorMsg, $e, $value))->jsRender(),
                          ]));
                    }
                });
            }
        }

        return $this->model;
    }
120578
public static function import(Model $model)
    {
        Utils\Utils::arrayPathSet(self::$models, self::getPath($model), $model);
    }