src/Listify.php
protected function getConditionStringFromQueryBuilder(QueryBuilder $query)
    {
        $initialQueryChunks = explode('where ', $query->toSql());

        if (count($initialQueryChunks) == 1) {
            throw new InvalidArgumentException(
                'The query builder instance must have a where clause to build a condition string from'
            );
        }

        $queryChunks = explode('?', $initialQueryChunks[1]);
        $chunkCount  = count($queryChunks);
        $bindings    = $query->getBindings();
        $whereString = '';

        for ($i = 0; $i < $chunkCount; $i++) {

            $whereString .= $queryChunks[ $i ];

            if (isset($bindings[ $i ])) {

                if (gettype($bindings[ $i ]) === 'string') {
                    $whereString .= '"' . $bindings[ $i ] . '"';
                }
            }
        }

        return $whereString;
    }
protected function getConditionStringFromQueryBuilder(QueryBuilder $query)
    {
        $initialQueryChunks = explode('where ', $query->toSql());

        if (count($initialQueryChunks) == 1) {
            throw new InvalidArgumentException(
                'The query builder instance must have a where clause to build a condition string from'
            );
        }

        $queryChunks = explode('?', $initialQueryChunks[1]);
        $chunkCount  = count($queryChunks);
        $bindings    = $query->getBindings();
        $whereString = '';

        for ($i = 0; $i < $chunkCount; $i++) {

            $whereString .= $queryChunks[ $i ];

            if (isset($bindings[ $i ])) {

                if (gettype($bindings[ $i ]) === 'string') {
                    $whereString .= '"' . $bindings[ $i ] . '"';
                }
            }
        }

        return $whereString;
    }
protected function getConditionStringFromQueryBuilder ( QueryBuilder $ query ) { $ initialQueryChunks = explode ( 'where ' , $ query -> toSql ( ) ) ; if ( count ( $ initialQueryChunks ) == 1 ) { throw new InvalidArgumentException ( 'The query builder instance must have a where clause to build a condition string from' ) ; } $ queryChunks = explode ( '?' , $ initialQueryChunks [ 1 ] ) ; $ chunkCount = count ( $ queryChunks ) ; $ bindings = $ query -> getBindings ( ) ; $ whereString = '' ; for ( $ i = 0 ; $ i < $ chunkCount ; $ i ++ ) { $ whereString .= $ queryChunks [ $ i ] ; if ( isset ( $ bindings [ $ i ] ) ) { if ( gettype ( $ bindings [ $ i ] ) === 'string' ) { $ whereString .= '"' . $ bindings [ $ i ] . '"' ; } } } return $ whereString ; }
Extracts a raw WHERE clause string from a QueryBuilder instance.
Note that this is practically identical to the original Listify.

@param QueryBuilder $query A Query Builder instance
@return string
Extracts a raw WHERE clause string from a QueryBuilder instance . Note that this is practically identical to the original Listify .