/**
* Update the cache for all operations.
*
* @param Model $model
*/
public function updateCache(Model $model)
{
$this->model = $model;
$this->applyToCountCache(function ($config) {
$foreignKey = $this->key($this->model, $config['foreignKey']);
if ($this->model->getOriginal($foreignKey) && $this->model->{$foreignKey} != $this->model->getOriginal($foreignKey)) {
$this->update($config, '-', $this->model->getOriginal($foreignKey));
$this->update($config, '+', $this->model->{$foreignKey});
}
});
}