src/Model/Customer.php
public function update($iCustomerId, array $aData = []): bool
    {
        try {

            $sKeyExistsLabel = array_key_exists('label', $aData);
            $sKeyExistsOrg   = array_key_exists('organisation', $aData);
            $sKeyExistsFirst = array_key_exists('first_name', $aData);
            $sKeyExistsLast  = array_key_exists('last_name', $aData);

            if ($sKeyExistsOrg && $sKeyExistsFirst && $sKeyExistsLast) {
                if (empty($aData['organisation']) && empty($aData['first_name']) && empty($aData['last_name'])) {
                    throw new InvoiceException('"organisation", "first_name" and "last_name" cannot all be empty.', 1);
                }
            }

            //  Only compile the label if the label isn't defined and any of the other fields are present
            if (!$sKeyExistsLabel && ($sKeyExistsOrg || $sKeyExistsFirst || $sKeyExistsLast)) {
                $aData['label'] = $this->compileLabel($aData);
            }

            return parent::update($iCustomerId, $aData);

        } catch (\Exception $e) {
            $this->setError($e->getMessage());
            return false;
        }
    }
public function update($iCustomerId, array $aData = []): bool
    {
        try {

            $sKeyExistsLabel = array_key_exists('label', $aData);
            $sKeyExistsOrg   = array_key_exists('organisation', $aData);
            $sKeyExistsFirst = array_key_exists('first_name', $aData);
            $sKeyExistsLast  = array_key_exists('last_name', $aData);

            if ($sKeyExistsOrg && $sKeyExistsFirst && $sKeyExistsLast) {
                if (empty($aData['organisation']) && empty($aData['first_name']) && empty($aData['last_name'])) {
                    throw new InvoiceException('"organisation", "first_name" and "last_name" cannot all be empty.', 1);
                }
            }

            //  Only compile the label if the label isn't defined and any of the other fields are present
            if (!$sKeyExistsLabel && ($sKeyExistsOrg || $sKeyExistsFirst || $sKeyExistsLast)) {
                $aData['label'] = $this->compileLabel($aData);
            }

            return parent::update($iCustomerId, $aData);

        } catch (\Exception $e) {
            $this->setError($e->getMessage());
            return false;
        }
    }
public function update ( $ iCustomerId , array $ aData = [ ] ) : bool { try { $ sKeyExistsLabel = array_key_exists ( 'label' , $ aData ) ; $ sKeyExistsOrg = array_key_exists ( 'organisation' , $ aData ) ; $ sKeyExistsFirst = array_key_exists ( 'first_name' , $ aData ) ; $ sKeyExistsLast = array_key_exists ( 'last_name' , $ aData ) ; if ( $ sKeyExistsOrg && $ sKeyExistsFirst && $ sKeyExistsLast ) { if ( empty ( $ aData [ 'organisation' ] ) && empty ( $ aData [ 'first_name' ] ) && empty ( $ aData [ 'last_name' ] ) ) { throw new InvoiceException ( '"organisation", "first_name" and "last_name" cannot all be empty.' , 1 ) ; } } //  Only compile the label if the label isn't defined and any of the other fields are present if ( ! $ sKeyExistsLabel && ( $ sKeyExistsOrg || $ sKeyExistsFirst || $ sKeyExistsLast ) ) { $ aData [ 'label' ] = $ this -> compileLabel ( $ aData ) ; } return parent :: update ( $ iCustomerId , $ aData ) ; } catch ( \ Exception $ e ) { $ this -> setError ( $ e -> getMessage ( ) ) ; return false ; } }
Update an existing customer

@param  integer $iCustomerId The ID of the customer to update
@param  array   $aData       The data to update the customer with

@return mixed
Update an existing customer