Ejemplo n.º 1
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($insert && ($parent = $this->parents(1)->one())) {
             $this->fields = $parent->fields;
         }
         if (!$this->fields || !is_array($this->fields)) {
             $this->fields = [];
         }
         $this->fields = json_encode($this->fields);
         return true;
     } else {
         return false;
     }
 }