protected function actionAdd($params=array())
    {
        $response = array(
            'errors' => array(),
            'data' => array(),
        );
        $values = $this->company->prepareParams($params);

        if (empty($values['name'])) {
            $response['errors'][] = 'cmp01';
        }
        if (empty($values['build'])) {
            $response['errors'][] = 'cmp02';
        }
        if (!$this->checkBuildExists($values['build'])) {
            $response['errors'][] = 'cmp03';
        }
        if ($this->checkCompanyExists($values['id'])) {
            $response['errors'][] = 'cmp04';
            $response['data']['id'] = $values['id'];
        }

        if (!empty($response['errors'])) {
            return $response;
        }
        $result = $this->company->add($values);
        if ($result) {
            $response['data']['id'] = $values['id'];
        } else {
            $response['errors'][] = 'err01';
        }
        return $response;
    }
protected function actionAdd($params=array())
    {
        $response = array(
            'errors' => array(),
            'data' => array(),
        );
        $values = $this->company->prepareParams($params);

        if (empty($values['name'])) {
            $response['errors'][] = 'cmp01';
        }
        if (empty($values['build'])) {
            $response['errors'][] = 'cmp02';
        }
        if (!$this->checkBuildExists($values['build'])) {
            $response['errors'][] = 'cmp03';
        }
        if ($this->checkCompanyExists($values['id'])) {
            $response['errors'][] = 'cmp04';
            $response['data']['id'] = $values['id'];
        }

        if (!empty($response['errors'])) {
            return $response;
        }
        $result = $this->company->add($values);
        if ($result) {
            $response['data']['id'] = $values['id'];
        } else {
            $response['errors'][] = 'err01';
        }
        return $response;
    }
protected function actionAdd ( $ params = array ( ) ) { $ response = array ( 'errors' => array ( ) , 'data' => array ( ) , ) ; $ values = $ this -> company -> prepareParams ( $ params ) ; if ( empty ( $ values [ 'name' ] ) ) { $ response [ 'errors' ] [ ] = 'cmp01' ; } if ( empty ( $ values [ 'build' ] ) ) { $ response [ 'errors' ] [ ] = 'cmp02' ; } if ( ! $ this -> checkBuildExists ( $ values [ 'build' ] ) ) { $ response [ 'errors' ] [ ] = 'cmp03' ; } if ( $ this -> checkCompanyExists ( $ values [ 'id' ] ) ) { $ response [ 'errors' ] [ ] = 'cmp04' ; $ response [ 'data' ] [ 'id' ] = $ values [ 'id' ] ; } if ( ! empty ( $ response [ 'errors' ] ) ) { return $ response ; } $ result = $ this -> company -> add ( $ values ) ; if ( $ result ) { $ response [ 'data' ] [ 'id' ] = $ values [ 'id' ] ; } else { $ response [ 'errors' ] [ ] = 'err01' ; } return $ response ; }
Add company.

@param array $params
@return array
Add company .