manifests_processor.php
/**
     * Process data sent by postflight
     *
     * @param string data
     * @author joncrain
     **/
Process data sent by postflight
@param string data
@author joncrain
Process data sent by postflight @param string data @author joncrain
function run($json)
    {
        if (!$json) {
            throw new Exception("Error Processing Request: No json data found", 1);
        }
        Manifests_model::where('serial_number', $this->serial_number)->delete();
        $data = json_decode($json, true);
        $fillable = [
            'serial_number' => $this->serial_number,
            'manifest_name' => '',
            'catalogs' => '',
            'included_manifests' => '',
            'managed_installs' => '',
            'managed_uninstalls' => '',
            'optional_installs' => '',
            'managed_updates' => '',
            'featured_items' => '',
            'condition_check' => '',
            'conditional_items' => '',
            'display_name' => '',
        ];
        $save_array = [];
        foreach ($data as $manifest_name => $manifest_array) {
            $temp = $fillable;
            $temp['manifest_name'] = $manifest_name;
            foreach ($manifest_array as $key => $value) {
                if ($key == 'conditional_items') {
                    $temp[$key] = json_encode($value);
                } else if ($key == 'display_name' || $key == 'condition_check') {
                    $temp[$key] = $value;
                } else if (array_key_exists($key, $temp)) {
                    $temp[$key] = implode(", ", $value);
                }
            }
            $save_array[] = $temp;
        }
        Manifests_model::insertChunked(
            $save_array
        );
    }
function run ( $ json ) { if ( ! $ json ) { throw new Exception ( " Error Processing Request: No json data found " , 1 ) ; } Manifests_model :: where ( 'serial_number' , $ this -> serial_number ) -> delete ( ) ; $ data = json_decode ( $ json , true ) ; $ fillable = [ 'serial_number' => $ this -> serial_number , 'manifest_name' => '' , 'catalogs' => '' , 'included_manifests' => '' , 'managed_installs' => '' , 'managed_uninstalls' => '' , 'optional_installs' => '' , 'managed_updates' => '' , 'featured_items' => '' , 'condition_check' => '' , 'conditional_items' => '' , 'display_name' => '' , ] ; $ save_array = [ ] ; foreach ( $ data as $ manifest_name => $ manifest_array ) { $ temp = $ fillable ; $ temp [ 'manifest_name' ] = $ manifest_name ; foreach ( $ manifest_array as $ key => $ value ) { if ( $ key == 'conditional_items' ) { $ temp [ $ key ] = json_encode ( $ value ) ; } else if ( $ key == 'display_name' || $ key == 'condition_check' ) { $ temp [ $ key ] = $ value ; } else if ( array_key_exists ( $ key , $ temp ) ) { $ temp [ $ key ] = implode ( " ,  " , $ value ) ; } } $ save_array [ ] = $ temp ; } Manifests_model :: insertChunked ( $ save_array ) ; }
Process data sent by postflight
 @param string data
 @author joncrain
Process data sent by postflight @param string data @author joncrain
// Check if data was uploaded // Delete previous set         // Process json into object thingy // Get fillable items // Get an instance of the fillable array // Add name to temp // conditional items need more processing // encode as JSON for processing later