Пример #1
0
 /**
  * Find the model based on the identifier. If the identifier does not exists in the database, create
  * new record in the database.
  *
  * @return object \admin\models\StorageFilter
  */
 public function findModel()
 {
     // find filter model based on the identifier
     $model = StorageFilter::find()->where(['identifier' => $this->identifier()])->one();
     // if no model exists, create new record
     if (!$model) {
         $model = new StorageFilter();
         $model->setAttributes(['name' => $this->name(), 'identifier' => $this->identifier()]);
         $model->insert(false);
         $this->addLog("added new filter '" . $this->identifier() . "' to database.");
     }
     return $model;
 }