����JFIF��x�x����'
| Server IP : 78.140.185.180 / Your IP : 216.73.216.170 Web Server : LiteSpeed System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : builderbox ( 1072) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/thread-self/root/home/builderbox/././www/common/Search/Drivers/Mysql/ |
Upload File : |
<?php namespace Common\Search\Drivers\Mysql;
use Arr;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Laravel\Scout\Builder;
use Laravel\Scout\Engines\Engine;
class MysqlSearchEngine extends Engine
{
/**
* Update the given model in the index.
*
* @param \Illuminate\Database\Eloquent\Collection $models
* @return void
*/
public function update($models)
{
//
}
/**
* Remove the given model from the index.
*
* @param \Illuminate\Database\Eloquent\Collection $models
* @return void
*/
public function delete($models)
{
//
}
public function search(Builder $builder)
{
return $this->performSearch($builder, ['perPage' => $builder->limit]);
}
public function paginate(Builder $builder, $perPage, $page): Collection
{
return $this->performSearch($builder, [
'limit' => $perPage,
'offset' => $perPage * $page - $perPage,
]);
}
protected function performSearch(
Builder $builder,
array $options = []
): Collection {
if ($builder->callback) {
return call_user_func(
$builder->callback,
null,
$builder->query,
$options,
);
}
$query = $builder->model->mysqlSearch($builder->query);
if (!empty($builder->orders)) {
foreach ($builder->orders as $order) {
$query->orderBy(
Arr::get($order, 'column'),
Arr::get($order, 'direction'),
);
}
}
if (isset($options['limit'])) {
$query = $query->take($options['limit']);
}
if (isset($options['offset'])) {
$query = $query->skip($options['offset']);
}
return $query->get();
}
/**
* Pluck and return the primary keys of the given results.
*
* @param mixed $results
* @return Collection
*/
public function mapIds($results)
{
return $results->pluck('id')->values();
}
/**
* Map the given results to instances of the given model.
*
* @param Builder $builder
* @param mixed $results
* @param Model $model
* @return \Illuminate\Database\Eloquent\Collection
*/
public function map(Builder $builder, $results, $model)
{
return $results;
}
/**
* Get the total count from a raw result returned by the engine.
*
* @param mixed $results
* @return int
*/
public function getTotalCount($results)
{
return count($results);
}
/**
* @inheritDoc
*/
public function flush($model)
{
//
}
public function lazyMap(Builder $builder, $results, $model)
{
return LazyCollection::make($results);
}
public function createIndex($name, array $options = [])
{
//
}
public function deleteIndex($name)
{
//
}
}