pmatseykanets / laravel-scout-postgres

PostgreSQL Full Text Search Engine for Laravel Scout
MIT License
159 stars 36 forks source link

Allow to customize the SQL search query #18

Closed tortuetorche closed 6 years ago

tortuetorche commented 6 years ago

NB: This pull request can be easily refactored, but I think this feature is really useful 😸

Use case:

$scoutEngine = App\Order::getModel()->searchableUsing();
list($query, $bindings) = $scoutEngine->buildSearch(
    App\Order::search('Star Trek')
);

// You can customize the SQL query here:
$query->addSelect('name');
// See: https://laravel.com/docs/5.6/queries

$orders = Illuminate\Support\Facades\DB::select($query->toSql(), $bindings->all());
tortuetorche commented 6 years ago

Maybe this pull request could be refactored with the help of a Closure and a extendQuery() method, something like https://laravel.com/docs/5.6/queries#parameter-grouping or https://laravel.com/docs/5.6/container#extending-bindings

tortuetorche commented 6 years ago

Closing in favor of https://github.com/pmatseykanets/laravel-scout-postgres/pull/19