LMongo\Eloquent\Relations\BelongsTo::addConstraints PHP Method

addConstraints() public method

Set the base constraints on the relation query.
public addConstraints ( ) : void
return void
    public function addConstraints()
    {
        // For belongs to relationships, which are essentially the inverse of has one
        // or has many relationships, we need to actually query on the primary key
        // of the related models matching on the foreign key that's on a parent.
        $key = $this->related->getKeyName();
        $this->query->where($key, new MongoID((string) $this->parent->{$this->foreignKey}));
    }