public function getRelationshipWheres($relationship, $tableAlias, $pivotAlias = null, $pivot = null)
    {
        //get the relationship model
        $relationshipModel = $relationship->getRelated();

        //get the query instance
        $query = $relationship->getQuery()->getQuery();

        //get the connection instance
        $connection = $query->getConnection();

        //one element of the relationship query's wheres is always useless (it will say pivot_table.other_id is null)
        //depending on whether or not softdeletes are enabled on the other model, this will be in either position 0
        //or 1 of the wheres array
        array_splice($query->wheres, (method_exists($relationshipModel, 'getDeletedAtColumn') ? 1 : 0), 1);

        //iterate over the wheres to properly alias the columns
        foreach ($query->wheres as &$where) {
            //alias the where columns
            $where['column'] = $this->aliasRelationshipWhere($where['column'], $tableAlias, $pivotAlias, $pivot);
        }

        $sql       = $query->toSql();
        $fullQuery = $this->interpolateQuery($sql, $connection->prepareBindings($query->getBindings()));
        $split     = explode(' where ', $fullQuery);

        return isset($split[1]) ? $split[1] : '';
    }
public function getRelationshipWheres($relationship, $tableAlias, $pivotAlias = null, $pivot = null)
    {
        //get the relationship model
        $relationshipModel = $relationship->getRelated();

        //get the query instance
        $query = $relationship->getQuery()->getQuery();

        //get the connection instance
        $connection = $query->getConnection();

        //one element of the relationship query's wheres is always useless (it will say pivot_table.other_id is null)
        //depending on whether or not softdeletes are enabled on the other model, this will be in either position 0
        //or 1 of the wheres array
        array_splice($query->wheres, (method_exists($relationshipModel, 'getDeletedAtColumn') ? 1 : 0), 1);

        //iterate over the wheres to properly alias the columns
        foreach ($query->wheres as &$where) {
            //alias the where columns
            $where['column'] = $this->aliasRelationshipWhere($where['column'], $tableAlias, $pivotAlias, $pivot);
        }

        $sql       = $query->toSql();
        $fullQuery = $this->interpolateQuery($sql, $connection->prepareBindings($query->getBindings()));
        $split     = explode(' where ', $fullQuery);

        return isset($split[1]) ? $split[1] : '';
    }
public function getRelationshipWheres ( $ relationship , $ tableAlias , $ pivotAlias = null , $ pivot = null ) { //get the relationship model $ relationshipModel = $ relationship -> getRelated ( ) ; //get the query instance $ query = $ relationship -> getQuery ( ) -> getQuery ( ) ; //get the connection instance $ connection = $ query -> getConnection ( ) ; //one element of the relationship query's wheres is always useless (it will say pivot_table.other_id is null) //depending on whether or not softdeletes are enabled on the other model, this will be in either position 0 //or 1 of the wheres array array_splice ( $ query -> wheres , ( method_exists ( $ relationshipModel , 'getDeletedAtColumn' ) ? 1 : 0 ) , 1 ) ; //iterate over the wheres to properly alias the columns foreach ( $ query -> wheres as & $ where ) { //alias the where columns $ where [ 'column' ] = $ this -> aliasRelationshipWhere ( $ where [ 'column' ] , $ tableAlias , $ pivotAlias , $ pivot ) ; } $ sql = $ query -> toSql ( ) ; $ fullQuery = $ this -> interpolateQuery ( $ sql , $ connection -> prepareBindings ( $ query -> getBindings ( ) ) ) ; $ split = explode ( ' where ' , $ fullQuery ) ; return isset ( $ split [ 1 ] ) ? $ split [ 1 ] : '' ; }
Sets up the existing relationship wheres.

@param \Illuminate\Database\Eloquent\Relations\Relation $relationship
@param string                                           $tableAlias
@param string                                           $pivotAlias
@param string                                           $pivot

@return string
Sets up the existing relationship wheres .