Get the query builder of the 'friend' model

@return \Illuminate\Database\Eloquent\Builder
6866
private function getMutualFriendsQueryBuilder(Model $other)
    {
        $user1['friendships'] = $this->findFriendships(Status::ACCEPTED)->get(['sender_id', 'recipient_id']);
        $user1['recipients'] = $user1['friendships']->pluck('recipient_id')->all();
        $user1['senders'] = $user1['friendships']->pluck('sender_id')->all();
        
        $user2['friendships'] = $other->findFriendships(Status::ACCEPTED)->get(['sender_id', 'recipient_id']);
        $user2['recipients'] = $user2['friendships']->pluck('recipient_id')->all();
        $user2['senders'] = $user2['friendships']->pluck('sender_id')->all();
        
        $mutualFriendships = array_unique(
                                    array_intersect(
                                        array_merge($user1['recipients'], $user1['senders']),
                                        array_merge($user2['recipients'], $user2['senders'])
                                    )
                                );

        return $this->whereNotIn('id', [$this->getKey(), $other->getKey()])->whereIn('id', $mutualFriendships);
    }
897889
protected function findModel()
    {
        $class = $this->model;
        $query = $class::query();

        foreach ($this->input as $key => $value) {
            $where = is_array($value) ? 'whereIn' : 'where';
            $query->$where($key, $value);
        }

        return $query->get();
    }
206559
protected function buildQuery()
    {
        $foreignKey = $this->foreignKey;
        $localKey   = $this->localKey;

        // 关联查询
        $pk = $this->parent->getPk();

        $condition[] = ['pivot.' . $localKey, '=', $this->parent->$pk];

        return $this->belongsToManyQuery($foreignKey, $localKey, $condition);
    }
22259
protected function getDeleteQuery()
    {
        return $this->newQueryWithoutRelationships()->where([
            $this->foreignKey => $this->getOriginal($this->foreignKey, $this->getAttribute($this->foreignKey)),
            $this->relatedKey => $this->getOriginal($this->relatedKey, $this->getAttribute($this->relatedKey)),
        ]);
    }
1278852
def get_query_builder(self, *args, **kwargs):
        
        query_builder = self.get_query_builder_class()
        return query_builder(*args, **kwargs)
1138924
public function getQuery()
    {
        $query = parent::getQuery();

        if (!is_null($query)) {
            $query->setHint(
                \Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER,
                'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'
            );
            $query->useQueryCache(false);
        }

        return $query;
    }
1312249
public function get()
    {
        // if exists the where or similar things in the query
        // call the from instance
        if (static::$_instance instanceof Builder) {

            $this->source = static::$_instance->get();
        } else {
            // if not call the parent directly
            $this->source = parent::all();
        }

        if (!static::$nested) {
            return $this->source;
        }

        return $this->to(static::$to);
    }
633600
protected function newBaseQueryBuilder()
    {
        $connection = $this->getConnection();
        // Check the connection type
        if ($connection instanceof \duxet\Rethinkdb\Connection) {
            return new QueryBuilder($connection);
        }

        return parent::newBaseQueryBuilder();
    }
1193357
public function build()
    {

        $query = $this->getQuery();
        $manager = new BuildManager($this->getBase()->getConnection());
        $manager->setPage($this->page);
        $manager->setQuery($query);
        $manager->setParams($this->string['parameters']);

        return $manager;
    }
849197
protected function newBaseQueryBuilder()
    {
        $connection = $this->getConnection();

        return new QueryBuilder($connection, $connection->getQueryGrammar(), $connection->getPostProcessor());
    }
575372
public function getFriend() {

		$userTable = CoreTables::getTableName( CoreTables::TABLE_USER );

		return $this->hasOne( User::class, [ 'id' => 'friendId' ] )->from( "$userTable as friend" );
	}
998729
public function createQueryBuilder()
	{
		$q = $this->flupdo->select();
		$this->queryAddFrom($q);
		$this->queryAddAccessPolicyCondition($this->read_access_policy, $q);
		return $q;
	}
808140
protected function newBaseQueryBuilder()
    {
        $conn = $this->getConnection();

        $grammar = $conn->getQueryGrammar();

        $builder = new Builder($conn, $grammar, $conn->getPostProcessor());

        if (isset($this->rememberFor)) {
            $builder->remember($this->rememberFor);
        }

        if (isset($this->rememberCacheTag)) {
            $builder->cacheTags($this->rememberCacheTag);
        }

        if (isset($this->rememberCachePrefix)) {
            $builder->prefix($this->rememberCachePrefix);
        }

        if (isset($this->rememberCacheDriver)) {
            $builder->cacheDriver($this->rememberCacheDriver);
        }

        return $builder;
    }
819703
private function createConversationQueryBuilder()
    {
        return $this->objectManager->createQueryBuilder()
            ->select('c', 'cp', 'p', 't', 'm', 'mp')
            ->from($this->getConversationClass(), 'c')
            ->leftJoin('c.persons', 'cp')
            ->leftJoin('cp.person', 'p')
            ->leftJoin('cp.tags', 't')
            ->leftJoin('c.messages', 'm')
            ->leftJoin('m.persons', 'mp')
            ->orderBy('m.date', 'ASC')
            ->addOrderBy('m.id', 'ASC');
    }
358077
protected function getQuery()
    {
        $query = new Query();

        if ($this->valid()) {
            $query->setQuery(new GtNode($this->dataStore->getIdentifier(), $this->key()));
        }

        $query->setLimit(new LimitNode($this->limit));
        $query->setSort(new SortNode([$this->dataStore->getIdentifier() => SortNode::SORT_ASC]));

        return $query;
    }
590312
public static function query()
    {
        $query = new Query(get_called_class());
        $query->set_searchable_fields(static::get_searchable_fields());
        $query->set_primary_key(static::get_primary_key());

        return $query;
    }
234046
public function getQueryBuilder($instance = null)
    {
        if (!$instance) {
            $instance = $this->query;
        }

        if ($this->isQueryBuilder()) {
            return $instance;
        }

        return $instance->getQuery();
    }