Exemplo n.º 1
0
 /**
  * Parses the warden config.
  *
  * @return array
  */
 public function toArray()
 {
     $attr = !empty($this->getWarden()) ? $this->getWarden() : null;
     if (empty($attr)) {
         $attr = empty($this->getVisible()) ? $this->getFillable() : $this->getVisible();
     }
     $returnable = [];
     $f_model = \FormModel::using('plain')->withModel($this);
     foreach ($attr as $old => $new) {
         if (!empty($relations = $f_model->getRelationalDataAndModels($this, $old))) {
             $returnable[$new] = $relations;
         }
         if (stripos($old, '_id') !== false) {
             if (!empty($this->{$new})) {
                 $returnable[$new] = $relations;
             }
         } else {
             if (isset($this->{$old})) {
                 $returnable[$new] = $this->{$old};
             }
         }
     }
     return $returnable;
 }