public function fillModel(&$model, \Illuminate\Http\Request $input, array $fields)
    {
        //run through the edit fields to see if we need to unset relationships or uneditable fields
        foreach ($fields as $name => $field) {
            if (!$field->getOption('external') && $field->getOption('editable')) {
                $field->fillModel($model, $input->get($name, null));
            }
            //if this is an "external" field (i.e. it's not a column on this model's table) or uneditable, unset it
            elseif ($name !== $model->getKeyName()) {
                $model->__unset($name);
            }
        }

        //loop through the fields again to unset any setter fields
        foreach ($fields as $name => $field) {
            $type = $field->getOption('type');

            if (($field->getOption('setter') && $type !== 'password') || ($type === 'password' && empty($model->{$name}))) {
                $model->__unset($name);
            }
        }
    }