mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
meilisearch return search_box_id
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Models\Category;
|
||||
use App\Models\Icon;
|
||||
use App\Models\NexusModel;
|
||||
use App\Models\SearchBox;
|
||||
use App\Models\Torrent;
|
||||
use App\Repositories\SearchBoxRepository;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
@@ -46,7 +47,19 @@ class CategoryResource extends Resource
|
||||
Forms\Components\Select::make('mode')
|
||||
->options(SearchBox::listModeOptions())
|
||||
->label(__('label.search_box.label'))
|
||||
->required()
|
||||
->rules([
|
||||
'required',
|
||||
function () {
|
||||
return function ($attribute, $value, $fail) {
|
||||
//@todo how to get the editing record ?
|
||||
$exists = Torrent::query()->where('category', $value)->exists();
|
||||
do_log("check $attribute: $value torrent if exists: $exists");
|
||||
// if ($exists) {
|
||||
// $fail("There are torrents belonging to this category that cannot be changed!");
|
||||
// }
|
||||
};
|
||||
}
|
||||
])
|
||||
,
|
||||
Forms\Components\TextInput::make('name')->required()->label(__('label.search_box.taxonomy.name'))->required(),
|
||||
Forms\Components\TextInput::make('image')
|
||||
|
||||
@@ -267,13 +267,21 @@ class MeiliSearchRepository extends BaseRepository
|
||||
$torrentIdArr = array_column($searchResult->getHits(), 'id');
|
||||
$fields = Torrent::getFieldsForList();
|
||||
$idStr = implode(',', $torrentIdArr);
|
||||
$results['list'] = Torrent::query()
|
||||
$torrents = Torrent::query()
|
||||
->select($fields)
|
||||
->with('basic_category')
|
||||
->whereIn('id', $torrentIdArr)
|
||||
->orderByRaw("field(id,$idStr)")
|
||||
->get()
|
||||
->toArray()
|
||||
;
|
||||
$list = [];
|
||||
foreach ($torrents as $torrent) {
|
||||
$searchBoxId = $torrent->basic_category->mode;
|
||||
$arr = $torrent->toArray();
|
||||
$arr['search_box_id'] = $searchBoxId;
|
||||
$list[] = $arr;
|
||||
}
|
||||
$results['list'] = $list;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.0');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-04-06');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-04-07');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
Reference in New Issue
Block a user