protected function foreignIDFilter($id = null)
    {
        if ($id === null) {
            $id = $this->getForeignID();
        }

        // Apply relation filter
        $key = "\"{$this->joinTable}\".\"{$this->foreignKey}\"";
        if (is_array($id)) {
            return ["$key IN (" . DB::placeholders($id) . ")"  => $id];
        }
        if ($id !== null) {
            return [$key => $id];
        }
        return null;
    }