nicolaslopezj / searchable

A php trait to search laravel models
MIT License
2.01k stars 291 forks source link

How to change the search method name ? #186

Open ysyap1104 opened 5 years ago

ysyap1104 commented 5 years ago

Hi everyone,

Im using searchable traits in my website and I would like to know how can I change the method name search into something else?

Ex: user::search($query) to user::searchScope($query)

Thank you for your help.

trijulio commented 4 years ago

You can find the SearchableTrait.php file and cange the name of the Scope

    public function scopeSearch(Builder $q, $search, $threshold = null, $entireText = false, $entireTextOnly = false)
    {
        return $this->scopeSearchRestricted($q, $search, null, $threshold, $entireText, $entireTextOnly);
    }

To:


    public function scopeSearchScope(Builder $q, $search, $threshold = null, $entireText = false, $entireTextOnly = false)
    {
        return $this->scopeSearchRestricted($q, $search, null, $threshold, $entireText, $entireTextOnly);
    }