Update search, update matching

This commit is contained in:
DariusIII
2019-01-21 11:27:47 +01:00
parent f62188ecf5
commit 26bb14e290
7 changed files with 39 additions and 24 deletions
+5 -4
View File
@@ -173,16 +173,17 @@ class Predb extends Model
}
/**
* @param string $search
* @param array $search
*
* @return mixed
* @throws \Exception
*/
public static function getAll($search = '')
public static function getAll($search = [])
{
$sql = self::query()->remember(config('nntmux.cache_expiry_medium'))->leftJoin('releases', 'releases.predb_id', '=', 'predb.id')->orderByDesc('predb.predate');
if ($search !== '') {
if (! empty($search)) {
$sphinx = new SphinxSearch();
$ids = array_pluck($sphinx->searchIndexes($search, 'title', 'predb_rt'), 'id');
$ids = array_pluck($sphinx->searchIndexes('predb_rt', $search, 'title'), 'id');
$sql->whereIn('predb.id', $ids);
}