public function afterCreate()
    {
        //setup the user notificatoin setting
        $companySettings = new CompanySettings();
        $companySettings->company_id = $this->getId();
        $companySettings->name = 'notifications';
        $companySettings->value = $this->user->email;
        if (!$companySettings->save()) {
            throw new Exception(current($companySettings->getMessages()));
        }

        //multi user asociation
        $usersAssociatedCompany = new UsersAssociatedCompany();
        $usersAssociatedCompany->users_id = $this->user->getId();
        $usersAssociatedCompany->company_id = $this->getId();
        $usersAssociatedCompany->identify_id = $this->user->getId();
        $usersAssociatedCompany->user_active = 1;
        $usersAssociatedCompany->user_role = 'admin';
        if (!$usersAssociatedCompany->save()) {
            throw new Exception(current($usersAssociatedCompany->getMessages()));
        }

        //now that we setup de company and associated with the user we need to setup this as its default company
        if (!UserConfig::findFirst(['conditions' => 'users_id = ?0 and name = ?1', 'bind' => [$this->user->getId(), self::DEFAULT_COMPANY]])) {
            $userConfig = new UserConfig();
            $userConfig->users_id = $this->user->getId();
            $userConfig->name = self::DEFAULT_COMPANY;
            $userConfig->value = $this->getId();

            if (!$userConfig->save()) {
                throw new Exception(current($userConfig->getMessages()));
            }
        }
    }
public function afterCreate()
    {
        //setup the user notificatoin setting
        $companySettings = new CompanySettings();
        $companySettings->company_id = $this->getId();
        $companySettings->name = 'notifications';
        $companySettings->value = $this->user->email;
        if (!$companySettings->save()) {
            throw new Exception(current($companySettings->getMessages()));
        }

        //multi user asociation
        $usersAssociatedCompany = new UsersAssociatedCompany();
        $usersAssociatedCompany->users_id = $this->user->getId();
        $usersAssociatedCompany->company_id = $this->getId();
        $usersAssociatedCompany->identify_id = $this->user->getId();
        $usersAssociatedCompany->user_active = 1;
        $usersAssociatedCompany->user_role = 'admin';
        if (!$usersAssociatedCompany->save()) {
            throw new Exception(current($usersAssociatedCompany->getMessages()));
        }

        //now that we setup de company and associated with the user we need to setup this as its default company
        if (!UserConfig::findFirst(['conditions' => 'users_id = ?0 and name = ?1', 'bind' => [$this->user->getId(), self::DEFAULT_COMPANY]])) {
            $userConfig = new UserConfig();
            $userConfig->users_id = $this->user->getId();
            $userConfig->name = self::DEFAULT_COMPANY;
            $userConfig->value = $this->getId();

            if (!$userConfig->save()) {
                throw new Exception(current($userConfig->getMessages()));
            }
        }
    }
public function afterCreate ( ) { //setup the user notificatoin setting $ companySettings = new CompanySettings ( ) ; $ companySettings -> company_id = $ this -> getId ( ) ; $ companySettings -> name = 'notifications' ; $ companySettings -> value = $ this -> user -> email ; if ( ! $ companySettings -> save ( ) ) { throw new Exception ( current ( $ companySettings -> getMessages ( ) ) ) ; } //multi user asociation $ usersAssociatedCompany = new UsersAssociatedCompany ( ) ; $ usersAssociatedCompany -> users_id = $ this -> user -> getId ( ) ; $ usersAssociatedCompany -> company_id = $ this -> getId ( ) ; $ usersAssociatedCompany -> identify_id = $ this -> user -> getId ( ) ; $ usersAssociatedCompany -> user_active = 1 ; $ usersAssociatedCompany -> user_role = 'admin' ; if ( ! $ usersAssociatedCompany -> save ( ) ) { throw new Exception ( current ( $ usersAssociatedCompany -> getMessages ( ) ) ) ; } //now that we setup de company and associated with the user we need to setup this as its default company if ( ! UserConfig :: findFirst ( [ 'conditions' => 'users_id = ?0 and name = ?1' , 'bind' => [ $ this -> user -> getId ( ) , self :: DEFAULT_COMPANY ] ] ) ) { $ userConfig = new UserConfig ( ) ; $ userConfig -> users_id = $ this -> user -> getId ( ) ; $ userConfig -> name = self :: DEFAULT_COMPANY ; $ userConfig -> value = $ this -> getId ( ) ; if ( ! $ userConfig -> save ( ) ) { throw new Exception ( current ( $ userConfig -> getMessages ( ) ) ) ; } } }
After creating the company

@return void
After creating the company