protected function wheresToSubquery(SearchableSubquery $subquery)
    {
        $bindingKey = 0;

        $typesToMove = [
            'basic', 'in', 'notin', 'between', 'null',
            'notnull', 'date', 'day', 'month', 'year',
        ];

        // Here we are going to move all the where clauses that we might apply
        // on the subquery in order to improve performance, since this way
        // we can drastically reduce number of joined rows on subquery.
        foreach ((array) $this->query->wheres as $key => $where) {
            $type = strtolower($where['type']);

            $bindingsCount = $this->countBindings($where, $type);

            if (in_array($type, $typesToMove) && $this->model->hasColumn($where['column'])) {
                unset($this->query->wheres[$key]);

                $where['column'] = $this->model->getTable() . '.' . $where['column'];

                $subquery->getQuery()->wheres[] = $where;

                $whereBindings = $this->query->getRawBindings()['where'];

                $bindings = array_splice($whereBindings, $bindingKey, $bindingsCount);

                $this->query->setBindings($whereBindings, 'where');

                $this->query->addBinding($bindings, 'select');

            // if where is not to be moved onto the subquery, let's increment
            // binding key appropriately, so we can reliably move binding
            // for the next where clauses in the loop that is running.
            } else {
                $bindingKey += $bindingsCount;
            }
        }
    }