Don't log changes when the only thing that changed was the published
state or updated timestamp.  We check if there are any attributes
besides these that changed.

@param  Model  $model  The model being touched
@param  string $action
@return boolean
429650
static private function shouldWriteChange(Model $model, $action)
    {
        if (in_array($action, ['created', 'deleted'])) return true;
        $changed_attributes = array_keys($model->getDirty());
        $ignored = ['updated_at', 'public'];
        $loggable = array_diff($changed_attributes, $ignored);
        return count($loggable) > 0;
    }
289153
private function updateCounter(ModelEvent $event, $action)
    {
        if (!$this->constraint->isVersioningService()) {
            return;
        }

        $qb = $this->documentManager->createQueryBuilder($event->getCollectionClass());
        if ('update' == $action) {
            $qb->findAndUpdate()
                ->field('id')->equals($event->getCollectionId())
                ->field(VersionServiceConstraint::FIELD_NAME)->inc(1)
                ->getQuery()->execute();
        } else {
            $qb->findAndUpdate()
                ->field('id')->equals($event->getCollectionId())
                ->field(VersionServiceConstraint::FIELD_NAME)->set(1)
                ->getQuery()->execute();
        }
    }
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]);
		}
	}
1261510
private static function log($action, Logable $model) {
		$modelId = $model->getLogName();
		if (empty($modelId)) :
			throw new \InvalidArgumentException("model_id must be set, it is currently {$model->getLogName()}");
		endif;

		$obj = Model\Action::where('name', '=', $action)->limit(1)->get();
		if ($obj->isEmpty()) :
			throw new \InvalidArgumentException("{$action} is not a valid action");
		endif;

		$message = new Model\Message;
		$message->action()->associate($obj[0]);
		$message->model = get_class($model);
		$message->model_id = $modelId;
		$message->save();

		return $message;
	}
828375
public function link(Model $model)
    {
        if ( ! $this->routePrefix || ! $this->isPermitted) {
            return false;
        }

        return route($this->routePrefix . static::ROUTE_POSTFIX, [ $model->getKey() ]);
    }
648793
public static function wasCreatedRecently(Model $model)
    {
        if (isset($model->created_at)) {

            $now = Carbon::now();

            if($model->created_at->lte($now) && $model->created_at->gte($now->subMinutes(static::RECENTLY))) {
                return true;
            }
        }

        return false;
    }
210720
def event_happened(event_name, model)
      self.last_action = event_name
      self.last_updated_node = model
      self.updated_at = Time.zone.now
      self.save!
    end
872818
public function beforeAction($action)
    {
        if (!parent::beforeAction($action)) {
            return false;
        }
        if ($this->accessType === 0) {
            return $this->module->goPodium();
        }
        return true;
    }
847074
public function beforeAction($action)
    {
        if (!parent::beforeAction($action)) {
            return false;
        }
        $warnings = Yii::$app->session->getFlash('warning');
        $maintenance = $this->maintenanceCheck($action, $warnings);
        if ($maintenance !== false) {
            return $maintenance;
        }
        $email = $this->emailCheck($warnings);
        if ($email !== false) {
            return $email;
        }
        $upgrade = $this->upgradeCheck($warnings);
        if ($upgrade !== false) {
            return $upgrade;
        }
        return true;
    }
1179656
public function created(Model $model)
    {
        $langs = app('languages')->langs();
        DB::beginTransaction();
        try {
            foreach ($langs as $lang) {
                $this->saveTranslatedMessage($model, $lang);
            }
        } catch (Exception $ex) {
            DB::rollback();
            throw $ex;
        }
        DB::commit();
        return true;
    }
80153
public function shouldLogChange($action)
    {
        if ($action != 'deleted'
            && count($this->getDirty()) == 1
            && $this->isDirty('remember_token')) {
            return false;
        }
        return parent::shouldLogChange($action);
    }
946959
public function undo(Model $Model) {
		if (!$Model->id) {
			trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
			return null;
		}
		if (!$Model->ShadowModel) {
			trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
			return false;
		}
		$data = $this->previous($Model);
		if (!$data) {
			$Model->logableAction['Revision'] = 'undo add';
			$Model->delete($Model->id);
			return false;
		}
		foreach ($Model->getAssociated('hasAndBelongsToMany') as $assocAlias) {
			if (isset($Model->ShadowModel->_schema[$assocAlias])) {
				$data[$assocAlias][$assocAlias] = explode(',', $data[$Model->alias][$assocAlias]);
			}
		}
		$Model->logableAction['Revision'] = 'undo changes';
		return (bool)$Model->save($data);
	}
1268144
public function saved($model)
    {
        if (static::syncingDisabledFor($model)) {
            return;
        }

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

            return;
        }

        $model->searchable();
    }
1140206
public function redirectAfter(Model $model, $action = null) {
        if (!$action) {
            $action = $this->Controller->request->data[$model->alias]['redirect_to'];
        }

        if ($action === 'parent') {
            $parentName = $this->Controller->request->data[$model->alias]['redirect_to_model'];
            $className = $model->belongsTo[$parentName]['className'];
            $foreignKey = $model->belongsTo[$parentName]['foreignKey'];
            $id = !empty($this->Controller->request->data[$model->alias][$foreignKey]) ? $this->Controller->request->data[$model->alias][$foreignKey] : null;
            $foreignModel = Admin::introspectModel($className);
            $url = array('plugin' => 'admin', 'controller' => 'crud', 'action' => $id ? 'read' : 'index', $id, 'model' => $foreignModel->urlSlug);

        } else {
            $url = array('plugin' => 'admin', 'controller' => 'crud', 'action' => $action, 'model' => $model->urlSlug);

            switch ($action) {
                case 'read':
                case 'update':
                case 'delete':
                    $url[] = $model->id;
                break;
            }

        }

        $this->Controller->redirect($url);
    }
1085394
public function delete(AbstractModel $model)
    {

        list($query, $param, $type) = $this->queryBuilder->generateDeleteForModel($model);

        if ($this->modelCache->get($model)) {
            $this->modelCache->remove($model);
        }
        
        $stmt = $this->prepare($query, $param);

        if ($stmt->execute()) {
            return true;

        } else {
            $this->log(ILog::T_ERROR, print_r($stmt->errorInfo(), true));
            return false;
        }
    }
589661
public function onPreviewHtmlReport(Model $model)
    {
        $this->onReportsHistory();
        Breadcrumbs::register('logger-reports-preview-' . $model->id, function($breadcrumbs) use($model) {
            $breadcrumbs->parent('logger-reports-history');
            $breadcrumbs->push('Preview report ' . $model->name, handles('antares::logger/view/' . $model->id));
        });
        view()->share('breadcrumbs', Breadcrumbs::render('logger-reports-preview-' . $model->id));
    }
331071
protected function isSupported($action)
    {
        if (empty($this->endpointsSupported) || in_array($action, $this->endpointsSupported)) {
            return true;
        }

        return $this->actionNotSupported($action);
    }