public function save(\Illuminate\Http\Request $input, array $fields)
    {
        $data  = array();
        $rules = $this->getOption('rules');

        //iterate over the edit fields to only fetch the important items
        foreach ($fields as $name => $field) {
            if ($field->getOption('editable')) {
                $data[$name] = $input->get($name);

                //make sure the bool field is set correctly
                if ($field->getOption('type') === 'bool') {
                    $data[$name] = $data[$name] === 'true' || $data[$name] === '1' ? 1 : 0;
                }
            } else {
                //unset uneditable fields rules
                unset($rules[$name]);
            }
        }

        //validate the model
        $validation = $this->validateData($data, $rules, $this->getOption('messages'));

        //if a string was kicked back, it's an error, so return it
        if (is_string($validation)) {
            return $validation;
        }

        //run the beforeSave function if provided
        $beforeSave = $this->runBeforeSave($data);

        //if a string was kicked back, it's an error, so return it
        if (is_string($beforeSave)) {
            return $beforeSave;
        }

        //Save the JSON data
        $this->putToJson($data);
        $this->setDataModel($data);

        return true;
    }
public function save(\Illuminate\Http\Request $input, array $fields)
    {
        $data  = array();
        $rules = $this->getOption('rules');

        //iterate over the edit fields to only fetch the important items
        foreach ($fields as $name => $field) {
            if ($field->getOption('editable')) {
                $data[$name] = $input->get($name);

                //make sure the bool field is set correctly
                if ($field->getOption('type') === 'bool') {
                    $data[$name] = $data[$name] === 'true' || $data[$name] === '1' ? 1 : 0;
                }
            } else {
                //unset uneditable fields rules
                unset($rules[$name]);
            }
        }

        //validate the model
        $validation = $this->validateData($data, $rules, $this->getOption('messages'));

        //if a string was kicked back, it's an error, so return it
        if (is_string($validation)) {
            return $validation;
        }

        //run the beforeSave function if provided
        $beforeSave = $this->runBeforeSave($data);

        //if a string was kicked back, it's an error, so return it
        if (is_string($beforeSave)) {
            return $beforeSave;
        }

        //Save the JSON data
        $this->putToJson($data);
        $this->setDataModel($data);

        return true;
    }
public function save ( \ Illuminate \ Http \ Request $ input , array $ fields ) { $ data = array ( ) ; $ rules = $ this -> getOption ( 'rules' ) ; //iterate over the edit fields to only fetch the important items foreach ( $ fields as $ name => $ field ) { if ( $ field -> getOption ( 'editable' ) ) { $ data [ $ name ] = $ input -> get ( $ name ) ; //make sure the bool field is set correctly if ( $ field -> getOption ( 'type' ) === 'bool' ) { $ data [ $ name ] = $ data [ $ name ] === 'true' || $ data [ $ name ] === '1' ? 1 : 0 ; } } else { //unset uneditable fields rules unset ( $ rules [ $ name ] ) ; } } //validate the model $ validation = $ this -> validateData ( $ data , $ rules , $ this -> getOption ( 'messages' ) ) ; //if a string was kicked back, it's an error, so return it if ( is_string ( $ validation ) ) { return $ validation ; } //run the beforeSave function if provided $ beforeSave = $ this -> runBeforeSave ( $ data ) ; //if a string was kicked back, it's an error, so return it if ( is_string ( $ beforeSave ) ) { return $ beforeSave ; } //Save the JSON data $ this -> putToJson ( $ data ) ; $ this -> setDataModel ( $ data ) ; return true ; }
Attempts to save a settings page.

@param \Illuminate\Http\Request $input
@param array                    $fields

@return mixed //string if error, true if success
Attempts to save a settings page .