protected function guessForeignField()
    {
        // First we try to find a column that match the header pattern
        $columns = $this->getModelColumns();
        $names = Config::getHeadersPatterns();

        foreach ($columns as $column) {
            if (Helpers::strIs($names, $column)) {
                // At this point a column that match the header patter was found
                return $column;
            }
        }

        // At this point we know no column that match the header patters found.
        // Second we try to find a non-primary/non-foreign key column
        $primary = $this->getPrimaryKeyForForeignModel();
        $idPatterns = Config::getKeyPatterns();
        foreach ($columns as $column) {
            if ($column != $primary && !Helpers::strIs($idPatterns, $column)) {
                return $column;
            }
        }

        return $primary;
    }
protected function guessForeignField()
    {
        // First we try to find a column that match the header pattern
        $columns = $this->getModelColumns();
        $names = Config::getHeadersPatterns();

        foreach ($columns as $column) {
            if (Helpers::strIs($names, $column)) {
                // At this point a column that match the header patter was found
                return $column;
            }
        }

        // At this point we know no column that match the header patters found.
        // Second we try to find a non-primary/non-foreign key column
        $primary = $this->getPrimaryKeyForForeignModel();
        $idPatterns = Config::getKeyPatterns();
        foreach ($columns as $column) {
            if ($column != $primary && !Helpers::strIs($idPatterns, $column)) {
                return $column;
            }
        }

        return $primary;
    }
protected function guessForeignField ( ) { // First we try to find a column that match the header pattern $ columns = $ this -> getModelColumns ( ) ; $ names = Config :: getHeadersPatterns ( ) ; foreach ( $ columns as $ column ) { if ( Helpers :: strIs ( $ names , $ column ) ) { // At this point a column that match the header patter was found return $ column ; } } // At this point we know no column that match the header patters found. // Second we try to find a non-primary/non-foreign key column $ primary = $ this -> getPrimaryKeyForForeignModel ( ) ; $ idPatterns = Config :: getKeyPatterns ( ) ; foreach ( $ columns as $ column ) { if ( $ column != $ primary && ! Helpers :: strIs ( $ idPatterns , $ column ) ) { return $ column ; } } return $ primary ; }
Guesses the name of the foreign key.

@return string
Guesses the name of the foreign key .