src/Models/Record.php
public function save(array $data)
    {
        if (!$this->getModel()->isSingle()) {
            $id = $data['id'] ?? $this->id;
            $this->id = $id;
        }

        $columns = $this->data;
        foreach ($columns as $key => $column) {
            if (array_key_exists($key, $data)) {
                $column->setValue($data[$key]);
            } else {
                $column->setValue(null);
            }
        }

        $yaml = Yaml::dump($this->getData(), 5, 4, YAML::DUMP_MULTI_LINE_LITERAL_BLOCK | YAML::DUMP_OBJECT_AS_MAP);

        $fs = new Filesystem();
        $fs->dumpFile($this->getContentFilePath(), $yaml);
    }
public function save(array $data)
    {
        if (!$this->getModel()->isSingle()) {
            $id = $data['id'] ?? $this->id;
            $this->id = $id;
        }

        $columns = $this->data;
        foreach ($columns as $key => $column) {
            if (array_key_exists($key, $data)) {
                $column->setValue($data[$key]);
            } else {
                $column->setValue(null);
            }
        }

        $yaml = Yaml::dump($this->getData(), 5, 4, YAML::DUMP_MULTI_LINE_LITERAL_BLOCK | YAML::DUMP_OBJECT_AS_MAP);

        $fs = new Filesystem();
        $fs->dumpFile($this->getContentFilePath(), $yaml);
    }
public function save ( array $ data ) { if ( ! $ this -> getModel ( ) -> isSingle ( ) ) { $ id = $ data [ 'id' ] ?? $ this -> id ; $ this -> id = $ id ; } $ columns = $ this -> data ; foreach ( $ columns as $ key => $ column ) { if ( array_key_exists ( $ key , $ data ) ) { $ column -> setValue ( $ data [ $ key ] ) ; } else { $ column -> setValue ( null ) ; } } $ yaml = Yaml :: dump ( $ this -> getData ( ) , 5 , 4 , YAML :: DUMP_MULTI_LINE_LITERAL_BLOCK | YAML :: DUMP_OBJECT_AS_MAP ) ; $ fs = new Filesystem ( ) ; $ fs -> dumpFile ( $ this -> getContentFilePath ( ) , $ yaml ) ; }
Validates and saves record to disk.
@param array $data
Validates and saves record to disk .