atk4\data\Model::asModel PHP Method

asModel() public method

This will cast Model into another class without loosing state of your active record.
public asModel ( string $class, array $options = [] ) : Model
$class string
$options array
return Model
    public function asModel($class, $options = [])
    {
        $m = $this->newInstance($class, $options);
        // Warning. If condition is different on both models,
        // but the respective field's value is un-changed
        // there might be some related issues.
        $m->data = $this->data;
        $m->dirty = $this->dirty;
        $m->id = $this->id;
        // next we need to go over fields to see if any system
        // values have changed and mark them as dirty
        return $m;
    }