Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom search in CP with a named query scope #65

Merged
merged 2 commits into from
Aug 10, 2021

Conversation

Skullbock
Copy link
Contributor

Description

It would be cool to be able to customize the way the CP search works in the Listing page, by adding a scope named runwaySearch to your model.

public function scopeRunwaySearch($query, $search)
{
    $query->where('some_field', $search);
}

@duncanmcclean
Copy link
Member

Thanks, I'll take a look at this after work today or at some point during the weekend 👍

@duncanmcclean
Copy link
Member

What's your use case for needing to add a scope to just the search?

@Skullbock
Copy link
Contributor Author

Skullbock commented Aug 6, 2021 via email

@duncanmcclean
Copy link
Member

duncanmcclean commented Aug 6, 2021

Hmm, I'm just wondering if that's the right way to go about it....

What about if developers could customise the fields used when performing a search query? And if they're not configured, it would use all of them, like it does now.

// config/runway.php

'search' => [
   'fields' => ['title', 'some_field', 'user.name'],
],

What do you think - is that something that would work for you?

@Skullbock
Copy link
Contributor Author

Skullbock commented Aug 6, 2021 via email

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.

Thanks! I think I see where you're coming from - I didn't before - merging now!

@duncanmcclean duncanmcclean merged commit aeda16f into statamic-rad-pack:2.1 Aug 10, 2021
@duncanmcclean
Copy link
Member

Released in v2.1.6.

@Skullbock
Copy link
Contributor Author

Thanks!

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