¨4.0.1¨

This commit is contained in:
¨NW¨
2023-12-03 14:07:47 +00:00
parent c08b36d1b6
commit f35052522d
1112 changed files with 43019 additions and 24987 deletions

View File

@@ -5,6 +5,9 @@ namespace Modules\Support\Search;
use Laravel\Scout\Builder;
use Laravel\Scout\Engines\Engine;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Illuminate\Database\Eloquent\Model;
class MySqlSearchEngine extends Engine
{
@@ -13,26 +16,49 @@ class MySqlSearchEngine extends Engine
//
}
public function delete($models)
{
//
}
/**
* Pluck and return the primary keys of the given results.
*
* @param mixed $results
* @return \Illuminate\Support\Collection
*
* @return Collection
*/
public function mapIds($results)
{
return $results['results'];
}
/**
* Perform the given search on the engine.
*
* @param \Laravel\Scout\Builder $builder
* @param \Modules\Support\Search\Builder $builder
* @param int $perPage
* @param int $page
*
* @return mixed
*/
public function paginate(Builder $builder, $perPage, $page)
{
$builder->limit = $perPage;
$builder->offset = ($perPage * $page) - $perPage;
return $this->search($builder);
}
/**
* Perform the given search on the engine.
*
* @param Builder $builder
*
* @return mixed
*/
public function search(Builder $builder)
@@ -51,7 +77,7 @@ class MySqlSearchEngine extends Engine
$result['count'] = $query->count();
if (property_exists($builder, 'orders') && ! empty($builder->orders)) {
if (property_exists($builder, 'orders') && !empty($builder->orders)) {
foreach ($builder->orders as $order) {
$query->orderBy($order['column'], $order['direction']);
}
@@ -70,10 +96,94 @@ class MySqlSearchEngine extends Engine
return $result;
}
/**
* Map the given results to instances of the given model.
*
* @param Laravel\Scout\Builder $builder
* @param Model $model
*
* @return Collection
*/
public function map(Builder $builder, $results, $model)
{
return $results['results'];
}
/**
* Map the given results to instances of the given model via a lazy collection.
*
* @param Builder $builder
* @param mixed $results
* @param Model $model
*
* @return LazyCollection
*/
public function lazyMap(Builder $builder, $results, $model)
{
//
}
/**
* Get the totalPrice count from a raw result returned by the engine.
*
* @param mixed $results
*
* @return int
*/
public function getTotalCount($results)
{
return $results['count'];
}
/**
* Flush all the model's records from the engine.
*
* @param Model $model
*
* @return void
*/
public function flush($model)
{
//
}
/**
* 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)
{
//
}
/**
* Get the search query.
*
* @param \Laravel\Scout\Builder $builder
* @param Builder $builder
*
* @return string
*/
private function getSearchKeyword($builder)
@@ -84,90 +194,4 @@ class MySqlSearchEngine extends Engine
return '+' . preg_replace('/[-+~*()><@"]/', ' ', $builder->query) . '*';
}
/**
* Perform the given search on the engine.
*
* @param \Modules\Support\Search\Builder $builder
* @param int $perPage
* @param int $page
* @return mixed
*/
public function paginate(Builder $builder, $perPage, $page)
{
$builder->limit = $perPage;
$builder->offset = ($perPage * $page) - $perPage;
return $this->search($builder);
}
/**
* Map the given results to instances of the given model.
*
* @param Laravel\Scout\Builder $builder
* @param \Illuminate\Database\Eloquent\Model $model
* @return \Illuminate\Support\Collection
*/
public function map(Builder $builder, $results, $model)
{
return $results['results'];
}
/**
* 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)
{
//
}
/**
* Get the total count from a raw result returned by the engine.
*
* @param mixed $results
* @return int
*/
public function getTotalCount($results)
{
return $results['count'];
}
/**
* Flush all of the model's records from the engine.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @return void
*/
public function flush($model)
{
//
}
/**
* 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)
{
//
}
}