mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
change category basic
This commit is contained in:
@@ -12,6 +12,7 @@ use App\Models\Tag;
|
|||||||
use App\Models\Torrent;
|
use App\Models\Torrent;
|
||||||
use App\Models\TorrentTag;
|
use App\Models\TorrentTag;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use App\Repositories\SearchBoxRepository;
|
||||||
use App\Repositories\TagRepository;
|
use App\Repositories\TagRepository;
|
||||||
use App\Repositories\TorrentRepository;
|
use App\Repositories\TorrentRepository;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
@@ -301,13 +302,13 @@ class TorrentResource extends Resource
|
|||||||
})
|
})
|
||||||
->deselectRecordsAfterCompletion();
|
->deselectRecordsAfterCompletion();
|
||||||
}
|
}
|
||||||
|
// $actions[] = self::getBulkActionChangeCategory();
|
||||||
|
|
||||||
if (user_can('torrent-delete')) {
|
if (user_can('torrent-delete')) {
|
||||||
$actions[] = Tables\Actions\DeleteBulkAction::make('bulk-delete')->using(function (Collection $records) {
|
$actions[] = Tables\Actions\DeleteBulkAction::make('bulk-delete')->using(function (Collection $records) {
|
||||||
deletetorrent($records->pluck('id')->toArray());
|
deletetorrent($records->pluck('id')->toArray());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,17 +342,55 @@ class TorrentResource extends Resource
|
|||||||
$actions[] = Tables\Actions\DeleteAction::make('delete')->using(function ($record) {
|
$actions[] = Tables\Actions\DeleteAction::make('delete')->using(function ($record) {
|
||||||
deletetorrent($record->id);
|
deletetorrent($record->id);
|
||||||
});
|
});
|
||||||
// $actions[] = Tables\Actions\Action::make('view')
|
|
||||||
// ->action(function (Torrent $record) {
|
|
||||||
// return [
|
|
||||||
// 'modelContent' => new HtmlString("ssss")
|
|
||||||
// ];
|
|
||||||
// })
|
|
||||||
// ;
|
|
||||||
}
|
}
|
||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function getBulkActionChangeCategory(): Tables\Actions\BulkAction
|
||||||
|
{
|
||||||
|
return Tables\Actions\BulkAction::make('changeCategory')
|
||||||
|
->label(__('admin.resources.torrent.bulk_action_change_category'))
|
||||||
|
->form([
|
||||||
|
Forms\Components\Select::make('section_id')
|
||||||
|
->label(__('searchbox.section'))
|
||||||
|
->options(function() {
|
||||||
|
$rep = new SearchBoxRepository();
|
||||||
|
$list = $rep->listSections(false);
|
||||||
|
$result = [];
|
||||||
|
foreach ($list as $section) {
|
||||||
|
$result[$section->id] = $section->displaySectionName;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
})
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(fn (callable $set) => $set('section_id', null))
|
||||||
|
->required()
|
||||||
|
,
|
||||||
|
Forms\Components\Select::make('category')
|
||||||
|
->label(__('searchbox.category_label'))
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$sectionId = $get('section_id');
|
||||||
|
if (!$sectionId) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return Category::query()->where('mode', $sectionId)->pluck('name', 'id');
|
||||||
|
})
|
||||||
|
->reactive()
|
||||||
|
->required()
|
||||||
|
,
|
||||||
|
|
||||||
|
])
|
||||||
|
->action(function (Collection $records, array $data) {
|
||||||
|
// $torrentRep = new TorrentRepository();
|
||||||
|
// try {
|
||||||
|
// $data['torrent_id'] = $record->id;
|
||||||
|
// $torrentRep->approval(Auth::user(), $data);
|
||||||
|
// } catch (\Exception $exception) {
|
||||||
|
// do_log($exception->getMessage(), 'error');
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private static function shouldShowApproval(): bool
|
private static function shouldShowApproval(): bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -243,18 +243,20 @@ class SearchBoxRepository extends BaseRepository
|
|||||||
return Category::query()->whereIn('id', $idArr)->delete();
|
return Category::query()->whereIn('id', $idArr)->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listSections()
|
public function listSections($withCategoryAndTags = true)
|
||||||
{
|
{
|
||||||
$modeIds = [SearchBox::getBrowseMode()];
|
$modeIds = [SearchBox::getBrowseMode()];
|
||||||
if (SearchBox::isSpecialEnabled() && Permission::canUploadToSpecialSection()) {
|
if (SearchBox::isSpecialEnabled() && Permission::canUploadToSpecialSection()) {
|
||||||
$modeIds[] = SearchBox::getSpecialMode();
|
$modeIds[] = SearchBox::getSpecialMode();
|
||||||
}
|
}
|
||||||
$searchBoxList = SearchBox::query()->with("categories")->find($modeIds);
|
$searchBoxList = SearchBox::query()->with($withCategoryAndTags ? ['categories'] : [])->find($modeIds);
|
||||||
foreach ($searchBoxList as $searchBox) {
|
if ($withCategoryAndTags) {
|
||||||
if ($searchBox->showsubcat) {
|
foreach ($searchBoxList as $searchBox) {
|
||||||
$searchBox->loadSubCategories();
|
if ($searchBox->showsubcat) {
|
||||||
|
$searchBox->loadSubCategories();
|
||||||
|
}
|
||||||
|
$searchBox->loadTags();
|
||||||
}
|
}
|
||||||
$searchBox->loadTags();
|
|
||||||
}
|
}
|
||||||
return $searchBoxList;
|
return $searchBoxList;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class class_cache_redis {
|
|||||||
if (!empty($config['port'])) {
|
if (!empty($config['port'])) {
|
||||||
$params[] = $config['port'];
|
$params[] = $config['port'];
|
||||||
}
|
}
|
||||||
if (!empty($config['timeout'])) {
|
if (isset($config['timeout']) && is_numeric($config['timeout'])) {
|
||||||
$params[] = $config['timeout'];
|
$params[] = $config['timeout'];
|
||||||
}
|
}
|
||||||
$connectResult = $redis->connect(...$params);
|
$connectResult = $redis->connect(...$params);
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ return [
|
|||||||
'bulk_action_recommend' => '推荐',
|
'bulk_action_recommend' => '推荐',
|
||||||
'bulk_action_sp_state' => '优惠',
|
'bulk_action_sp_state' => '优惠',
|
||||||
'bulk_action_hr' => 'H&R',
|
'bulk_action_hr' => 'H&R',
|
||||||
|
'bulk_action_change_category' => '修改分类',
|
||||||
],
|
],
|
||||||
'seed_box_record' => [
|
'seed_box_record' => [
|
||||||
'toggle_status' => '更改状态',
|
'toggle_status' => '更改状态',
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
'section' => '分区',
|
||||||
'category_label' => '分类',
|
'category_label' => '分类',
|
||||||
'sub_category_source_label' => '来源',
|
'sub_category_source_label' => '来源',
|
||||||
'sub_category_medium_label' => '媒介',
|
'sub_category_medium_label' => '媒介',
|
||||||
|
|||||||
Reference in New Issue
Block a user