/**
  * Creates a new AuditTrail model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new AuditTrail();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 public function leaveTrail($action, $name = null, $value = null, $old_value = null)
 {
     $log = new AuditTrail();
     $log->old_value = $old_value;
     $log->new_value = $value;
     $log->action = $action;
     $log->model = $this->owner->className();
     // Gets a plain text version of the model name
     $log->model_id = (string) $this->getNormalizedPk();
     $log->field = $name;
     $log->stamp = $this->storeTimestamp ? time() : date($this->dateFormat);
     // If we are storing a timestamp lets get one else lets get the date
     $log->user_id = (string) $this->getUserId();
     // Lets get the user id
     return $log->save();
 }