public function setModel(\atk4\data\Model $m)
    {
        $this->table($m->table);

        foreach ($m->elements as $field) {
            // ignore not persisted model fields
            if (!$field instanceof \atk4\data\Field) {
                continue;
            }

            if ($field->never_persist) {
                continue;
            }

            if ($field instanceof \atk4\data\Field_SQL_Expression) {
                continue;
            }

            if ($field->short_name == $m->id_field) {
                $this->id($field->actual ?: $field->short_name);
                continue;
            }

            $this->field($field->actual ?: $field->short_name, ['type' => $field->type]);  // todo add more options here
        }

        return $m;
    }
public function setModel(\atk4\data\Model $m)
    {
        $this->table($m->table);

        foreach ($m->elements as $field) {
            // ignore not persisted model fields
            if (!$field instanceof \atk4\data\Field) {
                continue;
            }

            if ($field->never_persist) {
                continue;
            }

            if ($field instanceof \atk4\data\Field_SQL_Expression) {
                continue;
            }

            if ($field->short_name == $m->id_field) {
                $this->id($field->actual ?: $field->short_name);
                continue;
            }

            $this->field($field->actual ?: $field->short_name, ['type' => $field->type]);  // todo add more options here
        }

        return $m;
    }
public function setModel ( \ atk4 \ data \ Model $ m ) { $ this -> table ( $ m -> table ) ; foreach ( $ m -> elements as $ field ) { // ignore not persisted model fields if ( ! $ field instanceof \ atk4 \ data \ Field ) { continue ; } if ( $ field -> never_persist ) { continue ; } if ( $ field instanceof \ atk4 \ data \ Field_SQL_Expression ) { continue ; } if ( $ field -> short_name == $ m -> id_field ) { $ this -> id ( $ field -> actual ? : $ field -> short_name ) ; continue ; } $ this -> field ( $ field -> actual ? : $ field -> short_name , [ 'type' => $ field -> type ] ) ; // todo add more options here } return $ m ; }
Sets model.

@param \atk4\data\Model $m

@return \atk4\data\Model
Sets model .