protected function shouldAttributeBeFilterable(ModelAttributeDataInterface $attribute)
    {
        // If an attribute is a foreign key, it shouldn't be a filter by default.

        foreach ($this->info->relations as $key => $relation) {

            switch ($relation->type) {

                case RelationType::MORPH_TO:
                case RelationType::BELONGS_TO:
                case RelationType::BELONGS_TO_THROUGH:

                    $keys = $relation->foreign_keys ?: [];

                    if (in_array($attribute->name, $keys)) {
                        return false;
                    }
                    break;
            }
        }

        return true;
    }