Skip to content

Conversation

@godismyjudge95
Copy link
Contributor

We recently ran into an issue where the search on our Runway models was not working properly (as in it wasn't filtering at all): https://discord.com/channels/489818810157891584/1151898550305837086/1415710334219583518

After a bit of digging, I found out that it is because we are using the Orbit Eloquent driver for the model, and Orbit specifies the DB connection on a per model basis. This means that when this code is called for scoping the Runway search:

    public function scopeRunwaySearch(Builder $query, string $searchQuery)
    {
        $this->runwayResource()->blueprint()->fields()->all()
            ->filter(fn (Field $field) => Schema::hasColumn($this->getTable(), $field->handle()))
            ->reject(fn (Field $field) => $field->visibility() === 'computed')
            ->each(fn (Field $field) => $query->orWhere($this->getColumnForField($field->handle()), 'LIKE', '%'.$searchQuery.'%'));
    }

it gets the default DB connection and not the Orbit connection.

This is not an Orbit specific issue as this behavior would happen with any model that specifies a different DB connection than the default.

This PR adds a failing test and a simple fix to use the model's connection and subsequently schema builder to check for the columns' existence.

@godismyjudge95
Copy link
Contributor Author

Failing tests appear to be Github actions having issues again... 🫠
Implemented your suggestions.

Copy link
Member

@duncanmcclean duncanmcclean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@duncanmcclean duncanmcclean merged commit 2fedd08 into statamic-rad-pack:8.x Dec 12, 2025
20 checks passed
@github-actions
Copy link

Released as part of v8.8.3.

@godismyjudge95 godismyjudge95 deleted the fix/runway-search-on-model-connection branch December 12, 2025 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants