admin/controllers/Invoice.php
protected function getObjectFromPost()
    {
        $oInput = Factory::service('Input');
        $oUri   = Factory::service('Uri');
        $aData  = [
            'ref'             => $oInput->post('ref') ?: null,
            'state'           => $oInput->post('state') ?: null,
            'dated'           => $oInput->post('dated') ?: null,
            'currency'        => $oInput->post('currency') ?: null,
            'terms'           => (int) $oInput->post('terms') ?: 0,
            'customer_id'     => (int) $oInput->post('customer_id') ?: null,
            'additional_text' => $oInput->post('additional_text') ?: null,
            'items'           => [],
            'currency'        => $oInput->post('currency'),
        ];

        if ($oInput->post('items')) {
            foreach ($oInput->post('items') as $aItem) {

                //  @todo convert to pence using a model
                $aData['items'][] = [
                    'id'        => array_key_exists('id', $aItem) ? $aItem['id'] : null,
                    'quantity'  => array_key_exists('quantity', $aItem) ? $aItem['quantity'] : null,
                    'unit'      => array_key_exists('unit', $aItem) ? $aItem['unit'] : null,
                    'label'     => array_key_exists('label', $aItem) ? $aItem['label'] : null,
                    'body'      => array_key_exists('body', $aItem) ? $aItem['body'] : null,
                    'unit_cost' => array_key_exists('unit_cost', $aItem) ? intval($aItem['unit_cost'] * 100) : null,
                    'tax_id'    => array_key_exists('tax_id', $aItem) ? $aItem['tax_id'] : null,
                ];
            }
        }

        if ($oUri->rsegment(5) == 'edit') {
            unset($aData['ref']);
        }

        return $aData;
    }
protected function getObjectFromPost()
    {
        $oInput = Factory::service('Input');
        $oUri   = Factory::service('Uri');
        $aData  = [
            'ref'             => $oInput->post('ref') ?: null,
            'state'           => $oInput->post('state') ?: null,
            'dated'           => $oInput->post('dated') ?: null,
            'currency'        => $oInput->post('currency') ?: null,
            'terms'           => (int) $oInput->post('terms') ?: 0,
            'customer_id'     => (int) $oInput->post('customer_id') ?: null,
            'additional_text' => $oInput->post('additional_text') ?: null,
            'items'           => [],
            'currency'        => $oInput->post('currency'),
        ];

        if ($oInput->post('items')) {
            foreach ($oInput->post('items') as $aItem) {

                //  @todo convert to pence using a model
                $aData['items'][] = [
                    'id'        => array_key_exists('id', $aItem) ? $aItem['id'] : null,
                    'quantity'  => array_key_exists('quantity', $aItem) ? $aItem['quantity'] : null,
                    'unit'      => array_key_exists('unit', $aItem) ? $aItem['unit'] : null,
                    'label'     => array_key_exists('label', $aItem) ? $aItem['label'] : null,
                    'body'      => array_key_exists('body', $aItem) ? $aItem['body'] : null,
                    'unit_cost' => array_key_exists('unit_cost', $aItem) ? intval($aItem['unit_cost'] * 100) : null,
                    'tax_id'    => array_key_exists('tax_id', $aItem) ? $aItem['tax_id'] : null,
                ];
            }
        }

        if ($oUri->rsegment(5) == 'edit') {
            unset($aData['ref']);
        }

        return $aData;
    }
protected function getObjectFromPost ( ) { $ oInput = Factory :: service ( 'Input' ) ; $ oUri = Factory :: service ( 'Uri' ) ; $ aData = [ 'ref' => $ oInput -> post ( 'ref' ) ? : null , 'state' => $ oInput -> post ( 'state' ) ? : null , 'dated' => $ oInput -> post ( 'dated' ) ? : null , 'currency' => $ oInput -> post ( 'currency' ) ? : null , 'terms' => ( int ) $ oInput -> post ( 'terms' ) ? : 0 , 'customer_id' => ( int ) $ oInput -> post ( 'customer_id' ) ? : null , 'additional_text' => $ oInput -> post ( 'additional_text' ) ? : null , 'items' => [ ] , 'currency' => $ oInput -> post ( 'currency' ) , ] ; if ( $ oInput -> post ( 'items' ) ) { foreach ( $ oInput -> post ( 'items' ) as $ aItem ) { //  @todo convert to pence using a model $ aData [ 'items' ] [ ] = [ 'id' => array_key_exists ( 'id' , $ aItem ) ? $ aItem [ 'id' ] : null , 'quantity' => array_key_exists ( 'quantity' , $ aItem ) ? $ aItem [ 'quantity' ] : null , 'unit' => array_key_exists ( 'unit' , $ aItem ) ? $ aItem [ 'unit' ] : null , 'label' => array_key_exists ( 'label' , $ aItem ) ? $ aItem [ 'label' ] : null , 'body' => array_key_exists ( 'body' , $ aItem ) ? $ aItem [ 'body' ] : null , 'unit_cost' => array_key_exists ( 'unit_cost' , $ aItem ) ? intval ( $ aItem [ 'unit_cost' ] * 100 ) : null , 'tax_id' => array_key_exists ( 'tax_id' , $ aItem ) ? $ aItem [ 'tax_id' ] : null , ] ; } } if ( $ oUri -> rsegment ( 5 ) == 'edit' ) { unset ( $ aData [ 'ref' ] ) ; } return $ aData ; }
Get an object generated from the POST data

@return array
@throws \Nails\Common\Exception\FactoryException
Get an object generated from the POST data