Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
Support scout v9
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperLaiTW authored and msonowal committed Aug 10, 2021
1 parent c377525 commit 501babf
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"require": {
"php": "^7.2|^8.0",
"laravel/scout": "~6.0|~7.0|~8.0"
"laravel/scout": "~6.0|~7.0|~8.0|~9.0"
},
"require-dev": {
"phpunit/phpunit": "8.5.x-dev",
Expand Down
41 changes: 41 additions & 0 deletions src/Engines/MySQLEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Yab\MySQLScout\Engines;

use Illuminate\Support\LazyCollection;
use Yab\MySQLScout\Engines\Modes\ModeContainer;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\DB;
Expand Down Expand Up @@ -165,4 +166,44 @@ protected function shouldUseFallback($builder)
strlen($builder->query) < config('scout.mysql.min_fulltext_search_length')) ||
$this->fallbackSearchShouldBeUsedForModel($builder);
}

/**
* Map the given results to instances of the given model via a lazy collection.
*
* @param \Laravel\Scout\Builder $builder
* @param mixed $results
* @param \Illuminate\Database\Eloquent\Model $model
* @return \Illuminate\Support\LazyCollection
*/
public function lazyMap(Builder $builder, $results, $model)
{
if ($this->getTotalCount($results) === 0) {
return LazyCollection::empty();
}

return LazyCollection::make($results['results']->all());
}

/**
* Create a search index.
*
* @param string $name
* @param array $options
* @return mixed
*/
public function createIndex($name, array $options = [])
{

}

/**
* Delete a search index.
*
* @param string $name
* @return mixed
*/
public function deleteIndex($name)
{

}
}

0 comments on commit 501babf

Please sign in to comment.