mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
section basic
This commit is contained in:
@@ -90,7 +90,8 @@ class Test extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$r = SearchBox::getSubCatOptions();
|
||||
dd($r);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class Kernel extends ConsoleKernel
|
||||
$schedule->command('exam:checkout_cronjob')->everyMinute()->withoutOverlapping();
|
||||
$schedule->command('exam:update_progress --bulk=1')->hourly()->withoutOverlapping();
|
||||
$schedule->command('backup:cronjob')->everyMinute()->withoutOverlapping();
|
||||
$schedule->command('hr:update_status')->everyMinute()->withoutOverlapping();
|
||||
$schedule->command('hr:update_status')->everyTenMinutes()->withoutOverlapping();
|
||||
$schedule->command('hr:update_status --ignore_time=1')->hourly()->withoutOverlapping();
|
||||
$schedule->command('user:delete_expired_token')->dailyAt('04:00');
|
||||
$schedule->command('claim:settle')->hourly()->when(function () {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section;
|
||||
|
||||
use App\Filament\Resources\Section\AudioCodecResource\Pages;
|
||||
use App\Filament\Resources\Section\AudioCodecResource\RelationManagers;
|
||||
use App\Models\AudioCodec;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class AudioCodecResource extends CodecResource
|
||||
{
|
||||
protected static ?string $model = AudioCodec::class;
|
||||
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return parent::form($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return parent::table($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListAudioCodecs::route('/'),
|
||||
'create' => Pages\CreateAudioCodec::route('/create'),
|
||||
'edit' => Pages\EditAudioCodec::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\AudioCodecResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\AudioCodecResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateAudioCodec extends CreateRecord
|
||||
{
|
||||
protected static string $resource = AudioCodecResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\AudioCodecResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\AudioCodecResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditAudioCodec extends EditRecord
|
||||
{
|
||||
protected static string $resource = AudioCodecResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\AudioCodecResource\Pages;
|
||||
|
||||
use App\Filament\PageList;
|
||||
use App\Filament\Resources\Section\AudioCodecResource;
|
||||
use App\Models\AudioCodec;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListAudioCodecs extends PageList
|
||||
{
|
||||
protected static string $resource = AudioCodecResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getTableQuery(): Builder
|
||||
{
|
||||
return AudioCodec::query()->with('search_box')->orderBy('mode', 'asc');
|
||||
}
|
||||
}
|
||||
+52
-22
@@ -1,31 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System\SectionResource\RelationManagers;
|
||||
namespace App\Filament\Resources\Section;
|
||||
|
||||
use App\Filament\Resources\Section\CategoryResource\Pages;
|
||||
use App\Filament\Resources\Section\CategoryResource\RelationManagers;
|
||||
use App\Models\Category;
|
||||
use App\Models\Icon;
|
||||
use App\Models\SearchBox;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class CategoriesRelationManager extends RelationManager
|
||||
class CategoryResource extends Resource
|
||||
{
|
||||
protected static string $relationship = 'categories';
|
||||
protected static ?string $model = Category::class;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
protected static ?string $navigationIcon = 'heroicon-o-collection';
|
||||
|
||||
protected static function getModelLabel(): string
|
||||
protected static ?string $navigationGroup = 'Section';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
return __('label.search_box.category');
|
||||
return __('admin.sidebar.category');
|
||||
}
|
||||
|
||||
public static function getBreadcrumb(): string
|
||||
{
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('mode')
|
||||
->options(SearchBox::query()->pluck('name', 'id')->toArray())
|
||||
->label(__('label.search_box.label'))
|
||||
->required()
|
||||
,
|
||||
Forms\Components\TextInput::make('name')->required()->label(__('label.search_box.taxonomy.name'))->required(),
|
||||
Forms\Components\TextInput::make('image')
|
||||
->label(__('label.search_box.taxonomy.image'))
|
||||
@@ -46,6 +64,7 @@ class CategoriesRelationManager extends RelationManager
|
||||
->label(__('label.search_box.taxonomy.sort_index'))
|
||||
->helperText(__('label.search_box.taxonomy.sort_index_help'))
|
||||
,
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -54,31 +73,42 @@ class CategoriesRelationManager extends RelationManager
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('name')->label(__('label.search_box.taxonomy.name')),
|
||||
Tables\Columns\TextColumn::make('search_box.name')->label(__('label.search_box.label')),
|
||||
Tables\Columns\TextColumn::make('name')->label(__('label.search_box.taxonomy.name'))->searchable(),
|
||||
Tables\Columns\TextColumn::make('icon.name')->label(__('label.search_box.taxonomy.icon_id')),
|
||||
Tables\Columns\TextColumn::make('image')->label(__('label.search_box.taxonomy.image')),
|
||||
Tables\Columns\TextColumn::make('class_name')->label(__('label.search_box.taxonomy.class_name')),
|
||||
Tables\Columns\TextColumn::make('sort_index')->label(__('label.search_box.taxonomy.sort_index'))->sortable(),
|
||||
])
|
||||
->defaultSort('sort_index')
|
||||
->defaultSort('sort_index', 'asc')
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
Tables\Actions\CreateAction::make()->after(function ($record) {
|
||||
clear_search_box_cache($record->mode);
|
||||
}),
|
||||
Tables\Filters\SelectFilter::make('mode')
|
||||
->options(SearchBox::query()->pluck('name', 'id')->toArray())
|
||||
->label(__('label.search_box.label'))
|
||||
,
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make()->after(function ($record) {
|
||||
clear_search_box_cache($record->mode);
|
||||
}),
|
||||
Tables\Actions\DeleteAction::make()->after(function ($record) {
|
||||
clear_search_box_cache($record->mode);
|
||||
}),
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListCategories::route('/'),
|
||||
'create' => Pages\CreateCategory::route('/create'),
|
||||
'edit' => Pages\EditCategory::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\CategoryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\CategoryResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateCategory extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CategoryResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\CategoryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\CategoryResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditCategory extends EditRecord
|
||||
{
|
||||
protected static string $resource = CategoryResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\CategoryResource\Pages;
|
||||
|
||||
use App\Filament\PageList;
|
||||
use App\Filament\Resources\Section\CategoryResource;
|
||||
use App\Models\Category;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListCategories extends PageList
|
||||
{
|
||||
protected static string $resource = CategoryResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getTableQuery(): Builder
|
||||
{
|
||||
return Category::query()->with('search_box')->orderBy('mode', 'asc');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section;
|
||||
|
||||
use App\Filament\Resources\Section\CodecResource\Pages;
|
||||
use App\Filament\Resources\Section\CodecResource\RelationManagers;
|
||||
use App\Models\Codec;
|
||||
use App\Models\Icon;
|
||||
use App\Models\SearchBox;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class CodecResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Codec::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-bookmark';
|
||||
|
||||
protected static ?string $navigationGroup = 'Section';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')->required()->label(__('label.search_box.taxonomy.name'))->required(),
|
||||
Forms\Components\TextInput::make('sort_index')
|
||||
->default(0)
|
||||
->label(__('label.search_box.taxonomy.sort_index'))
|
||||
->helperText(__('label.search_box.taxonomy.sort_index_help'))
|
||||
,
|
||||
Forms\Components\Select::make('mode')
|
||||
->options(SearchBox::query()->pluck('name', 'id')->toArray())
|
||||
->label(__('label.search_box.taxonomy.mode'))
|
||||
->helperText(__('label.search_box.taxonomy.mode_help'))
|
||||
,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('search_box.name')
|
||||
->label(__('label.search_box.label'))
|
||||
->formatStateUsing(fn ($record) => $record->search_box->name ?? 'All')
|
||||
,
|
||||
Tables\Columns\TextColumn::make('name')->label(__('label.search_box.taxonomy.name'))->searchable(),
|
||||
Tables\Columns\TextColumn::make('sort_index')->label(__('label.search_box.taxonomy.sort_index'))->sortable(),
|
||||
])
|
||||
->defaultSort('sort_index', 'asc')
|
||||
->filters([
|
||||
Tables\Filters\SelectFilter::make('mode')
|
||||
->options(SearchBox::query()->pluck('name', 'id')->toArray())
|
||||
->label(__('label.search_box.taxonomy.mode'))
|
||||
->query(function (Builder $query, array $data) {
|
||||
return $query->where(function (Builder $query) use ($data) {
|
||||
return $query->where('mode', 0)->orWhere('mode', $data['value']);
|
||||
});
|
||||
})
|
||||
,
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListCodecs::route('/'),
|
||||
'create' => Pages\CreateCodec::route('/create'),
|
||||
'edit' => Pages\EditCodec::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\CodecResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\CodecResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateCodec extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CodecResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\CodecResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\CodecResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditCodec extends EditRecord
|
||||
{
|
||||
protected static string $resource = CodecResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\CodecResource\Pages;
|
||||
|
||||
use App\Filament\PageList;
|
||||
use App\Filament\Resources\Section\CodecResource;
|
||||
use App\Models\Codec;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListCodecs extends PageList
|
||||
{
|
||||
protected static string $resource = CodecResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getTableQuery(): Builder
|
||||
{
|
||||
return Codec::query()->with('search_box')->orderBy('mode', 'asc');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section;
|
||||
|
||||
use App\Filament\OptionsTrait;
|
||||
use App\Filament\Resources\Section\IconResource\Pages;
|
||||
use App\Filament\Resources\Section\IconResource\RelationManagers;
|
||||
use App\Models\Icon;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class IconResource extends Resource
|
||||
{
|
||||
use OptionsTrait;
|
||||
|
||||
protected static ?string $model = Icon::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-ticket';
|
||||
|
||||
protected static ?string $navigationGroup = 'Section';
|
||||
|
||||
protected static ?int $navigationSort = 10;
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
return __('admin.sidebar.icon');
|
||||
}
|
||||
|
||||
public static function getBreadcrumb(): string
|
||||
{
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label(__('label.name'))
|
||||
->required()
|
||||
,
|
||||
Forms\Components\TextInput::make('folder')
|
||||
->label(__('label.icon.folder'))
|
||||
->required()
|
||||
->helperText(__('label.icon.folder_help'))
|
||||
,
|
||||
Forms\Components\Radio::make('multilang')
|
||||
->label(__('label.icon.multilang'))
|
||||
->options(self::$yesOrNo)
|
||||
->required()
|
||||
->helperText(__('label.icon.multilang_help'))
|
||||
,
|
||||
Forms\Components\Radio::make('secondicon')
|
||||
->label(__('label.icon.secondicon'))
|
||||
->options(self::$yesOrNo)
|
||||
->required()
|
||||
->helperText(__('label.icon.secondicon_help'))
|
||||
,
|
||||
Forms\Components\TextInput::make('cssfile')->label(__('label.icon.cssfile'))->helperText(__('label.icon.cssfile_help')),
|
||||
Forms\Components\TextInput::make('designer')->label(__('label.icon.designer'))->helperText(__('label.icon.designer_help')),
|
||||
Forms\Components\Textarea::make('comment')->label(__('label.icon.comment'))->helperText(__('label.icon.comment_help')),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('name'),
|
||||
Tables\Columns\TextColumn::make('folder'),
|
||||
Tables\Columns\TextColumn::make('cssfile'),
|
||||
Tables\Columns\TextColumn::make('multilang'),
|
||||
Tables\Columns\TextColumn::make('secondicon'),
|
||||
Tables\Columns\TextColumn::make('designer'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListIcons::route('/'),
|
||||
'create' => Pages\CreateIcon::route('/create'),
|
||||
'edit' => Pages\EditIcon::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\IconResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\IconResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateIcon extends CreateRecord
|
||||
{
|
||||
protected static string $view = 'filament.resources.system.category-icon-resource.pages.create-record';
|
||||
|
||||
protected static string $resource = IconResource::class;
|
||||
|
||||
protected function getViewData(): array
|
||||
{
|
||||
return [
|
||||
'desc' => nexus_trans('label.icon.desc')
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\IconResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\IconResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditIcon extends EditRecord
|
||||
{
|
||||
protected static string $resource = IconResource::class;
|
||||
|
||||
protected static string $view = 'filament.resources.system.category-icon-resource.pages.edit-record';
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getViewData(): array
|
||||
{
|
||||
return [
|
||||
'desc' => nexus_trans('label.icon.desc')
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\IconResource\Pages;
|
||||
|
||||
use App\Filament\PageList;
|
||||
use App\Filament\Resources\Section\IconResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListIcons extends PageList
|
||||
{
|
||||
protected static string $resource = IconResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section;
|
||||
|
||||
use App\Filament\Resources\Section\MediaResource\Pages;
|
||||
use App\Filament\Resources\Section\MediaResource\RelationManagers;
|
||||
use App\Models\Media;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class MediaResource extends CodecResource
|
||||
{
|
||||
protected static ?string $model = Media::class;
|
||||
|
||||
protected static ?int $navigationSort = 8;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return parent::form($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return parent::table($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListMedia::route('/'),
|
||||
'create' => Pages\CreateMedia::route('/create'),
|
||||
'edit' => Pages\EditMedia::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\MediaResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\MediaResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateMedia extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MediaResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\MediaResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\MediaResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditMedia extends EditRecord
|
||||
{
|
||||
protected static string $resource = MediaResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\MediaResource\Pages;
|
||||
|
||||
use App\Filament\PageList;
|
||||
use App\Filament\Resources\Section\MediaResource;
|
||||
use App\Models\Media;
|
||||
use App\Models\Source;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListMedia extends PageList
|
||||
{
|
||||
protected static string $resource = MediaResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getTableQuery(): Builder
|
||||
{
|
||||
return Media::query()->with('search_box')->orderBy('mode', 'asc');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section;
|
||||
|
||||
use App\Filament\Resources\Section\ProcessingResource\Pages;
|
||||
use App\Filament\Resources\Section\ProcessingResource\RelationManagers;
|
||||
use App\Models\Processing;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class ProcessingResource extends CodecResource
|
||||
{
|
||||
protected static ?string $model = Processing::class;
|
||||
|
||||
protected static ?int $navigationSort = 9;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return parent::form($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return parent::table($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListProcessings::route('/'),
|
||||
'create' => Pages\CreateProcessing::route('/create'),
|
||||
'edit' => Pages\EditProcessing::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\ProcessingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\ProcessingResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateProcessing extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ProcessingResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\ProcessingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\ProcessingResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditProcessing extends EditRecord
|
||||
{
|
||||
protected static string $resource = ProcessingResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\ProcessingResource\Pages;
|
||||
|
||||
use App\Filament\PageList;
|
||||
use App\Filament\Resources\Section\ProcessingResource;
|
||||
use App\Models\Processing;
|
||||
use App\Models\Source;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListProcessings extends PageList
|
||||
{
|
||||
protected static string $resource = ProcessingResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getTableQuery(): Builder
|
||||
{
|
||||
return Processing::query()->with('search_box')->orderBy('mode', 'asc');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section;
|
||||
|
||||
use App\Filament\Resources\Section\SecondIconResource\Pages;
|
||||
use App\Filament\Resources\Section\SecondIconResource\RelationManagers;
|
||||
use App\Models\SearchBox;
|
||||
use App\Models\SecondIcon;
|
||||
use App\Models\Setting;
|
||||
use App\Repositories\SearchBoxRepository;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class SecondIconResource extends Resource
|
||||
{
|
||||
protected static ?string $model = SecondIcon::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-ticket';
|
||||
|
||||
protected static ?string $navigationGroup = 'Section';
|
||||
|
||||
protected static ?int $navigationSort = 11;
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
return __('admin.sidebar.second_icon');
|
||||
}
|
||||
|
||||
public static function getBreadcrumb(): string
|
||||
{
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
$searchBoxRep = new SearchBoxRepository();
|
||||
$torrentMode = Setting::get('main.browsecat');
|
||||
$specialMode = Setting::get('main.specialcat');
|
||||
$torrentTaxonomySchema = $searchBoxRep->listTaxonomyFormSchema($torrentMode);
|
||||
$specialTaxonomySchema = $searchBoxRep->listTaxonomyFormSchema($specialMode);
|
||||
$modeOptions = SearchBox::query()->whereIn('id', [$torrentMode, $specialMode])->pluck('name', 'id')->toArray();
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label(__('label.name'))
|
||||
->required()
|
||||
->helperText(__('label.second_icon.name_help'))
|
||||
,
|
||||
Forms\Components\Select::make('mode')
|
||||
->label(__('label.search_box.label'))
|
||||
->options($modeOptions)
|
||||
->required()
|
||||
->reactive()
|
||||
,
|
||||
Forms\Components\TextInput::make('image')
|
||||
->label(__('label.second_icon.image'))
|
||||
->required()
|
||||
->helperText(__('label.second_icon.image_help'))
|
||||
,
|
||||
Forms\Components\TextInput::make('class_name')
|
||||
->label(__('label.second_icon.class_name'))
|
||||
->helperText(__('label.second_icon.class_name_help'))
|
||||
,
|
||||
Forms\Components\Section::make(__('label.second_icon.select_section'))
|
||||
->id("taxonomy_$torrentMode")
|
||||
->schema($torrentTaxonomySchema)
|
||||
->columns(4)
|
||||
->hidden(fn (\Closure $get) => $get('mode') != $torrentMode)
|
||||
,
|
||||
Forms\Components\Section::make(__('label.second_icon.select_section'))
|
||||
->id("taxonomy_$specialMode")
|
||||
->schema($specialTaxonomySchema)
|
||||
->columns(4)
|
||||
->hidden(fn (\Closure $get) => $get('mode') != $specialMode)
|
||||
,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
$columns = [
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('search_box.name')
|
||||
->label(__('label.search_box.label'))
|
||||
->formatStateUsing(fn ($record) => $record->search_box->name ?? 'All')
|
||||
,
|
||||
Tables\Columns\TextColumn::make('name')->label(__('label.name')),
|
||||
Tables\Columns\TextColumn::make('image')->label(__('label.second_icon.image')),
|
||||
Tables\Columns\TextColumn::make('class_name')->label(__('label.second_icon.class_name')),
|
||||
];
|
||||
$taxonomyList = self::listTaxonomy();
|
||||
foreach (SearchBox::$taxonomies as $torrentField => $tableName) {
|
||||
$columns[] = Tables\Columns\TextColumn::make($torrentField)->formatStateUsing(function ($state) use ($taxonomyList, $torrentField) {
|
||||
return $taxonomyList[$torrentField]->get($state);
|
||||
});
|
||||
}
|
||||
return $table
|
||||
->columns($columns)
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
private static function listTaxonomy()
|
||||
{
|
||||
static $taxonomyList = [];
|
||||
if (empty($taxonomyList)) {
|
||||
foreach (SearchBox::$taxonomies as $torrentField => $tableName) {
|
||||
$taxonomyList[$torrentField] = NexusDB::table($tableName)->pluck('name', 'id');
|
||||
}
|
||||
}
|
||||
return $taxonomyList;
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListSecondIcons::route('/'),
|
||||
'create' => Pages\CreateSecondIcon::route('/create'),
|
||||
'edit' => Pages\EditSecondIcon::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\SecondIconResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\SecondIconResource;
|
||||
use App\Models\SearchBox;
|
||||
use App\Models\SecondIcon;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSecondIcon extends CreateRecord
|
||||
{
|
||||
protected static string $resource = SecondIconResource::class;
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
return SecondIcon::formatFormData($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\SecondIconResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\SecondIconResource;
|
||||
use App\Models\SearchBox;
|
||||
use App\Models\SecondIcon;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditSecondIcon extends EditRecord
|
||||
{
|
||||
protected static string $resource = SecondIconResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
{
|
||||
return SecondIcon::formatFormData($data);
|
||||
}
|
||||
|
||||
protected function mutateFormDataBeforeFill(array $data): array
|
||||
{
|
||||
$mode = $data['mode'];
|
||||
foreach (SearchBox::$taxonomies as $torrentField => $table) {
|
||||
$taxonomyValue = $data[$torrentField] ?? null;
|
||||
unset($data[$torrentField]);
|
||||
$data[$torrentField][$mode] = $taxonomyValue;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\SecondIconResource\Pages;
|
||||
|
||||
use App\Filament\PageList;
|
||||
use App\Filament\Resources\Section\SecondIconResource;
|
||||
use App\Models\SecondIcon;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListSecondIcons extends PageList
|
||||
{
|
||||
protected static string $resource = SecondIconResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getTableQuery(): Builder
|
||||
{
|
||||
return SecondIcon::query()->with('search_box');
|
||||
}
|
||||
}
|
||||
+28
-26
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System;
|
||||
namespace App\Filament\Resources\Section;
|
||||
|
||||
use App\Filament\Resources\System\SectionResource\Pages;
|
||||
use App\Filament\Resources\System\SectionResource\RelationManagers;
|
||||
use App\Http\Middleware\Locale;
|
||||
use App\Models\Forum;
|
||||
use App\Models\SearchBox;
|
||||
use App\Models\TorrentCustomField;
|
||||
@@ -27,9 +28,9 @@ class SectionResource extends Resource
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-view-boards';
|
||||
|
||||
protected static ?string $navigationGroup = 'System';
|
||||
protected static ?string $navigationGroup = 'Section';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
@@ -41,11 +42,26 @@ class SectionResource extends Resource
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
private static function buildLocalSchema($name)
|
||||
{
|
||||
$localeSchema = [];
|
||||
foreach (Locale::$languageMaps as $lang => $locale) {
|
||||
$localeSchema[] = Forms\Components\TextInput::make("$name.$lang")->required()->label($lang);
|
||||
}
|
||||
return $localeSchema;
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
$displayTextLocalSchema = self::buildLocalSchema('display_text');
|
||||
$sectionNameLocalSchema = self::buildLocalSchema('section_name');
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')->label(__('label.search_box.name'))->rules('alpha_dash')->required(),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label(__('label.search_box.name'))
|
||||
->rules('alpha_dash')
|
||||
->required()
|
||||
,
|
||||
Forms\Components\TextInput::make('catsperrow')
|
||||
->label(__('label.search_box.catsperrow'))
|
||||
->helperText(__('label.search_box.catsperrow_help'))
|
||||
@@ -60,10 +76,6 @@ class SectionResource extends Resource
|
||||
->required()
|
||||
->default(3)
|
||||
,
|
||||
Forms\Components\TextInput::make('section_name')
|
||||
->label(__('label.search_box.section_name'))
|
||||
->helperText(__('label.search_box.section_name_help'))
|
||||
,
|
||||
Forms\Components\CheckboxList::make('custom_fields')
|
||||
->options(TorrentCustomField::getCheckboxOptions())
|
||||
->label(__('label.search_box.custom_fields'))
|
||||
@@ -74,20 +86,19 @@ class SectionResource extends Resource
|
||||
Forms\Components\Textarea::make('custom_fields_display')
|
||||
->label(__('label.search_box.custom_fields_display'))
|
||||
->helperText(__('label.search_box.custom_fields_display_help'))
|
||||
->columnSpan(['sm' => 'full'])
|
||||
,
|
||||
Forms\Components\Toggle::make('is_default')
|
||||
->label(__('label.search_box.is_default'))
|
||||
->columnSpan(['sm' => 'full'])
|
||||
Forms\Components\Section::make(__('label.search_box.section_name'))
|
||||
->schema($sectionNameLocalSchema)
|
||||
->columns(count($sectionNameLocalSchema))
|
||||
,
|
||||
Forms\Components\Toggle::make('showsubcat')->label(__('label.search_box.showsubcat')),
|
||||
Forms\Components\Toggle::make('showsubcat')->label(__('label.search_box.showsubcat'))->columnSpan(['sm' => 'full']),
|
||||
Forms\Components\Section::make(__('label.search_box.showsubcat'))->schema([
|
||||
Forms\Components\Repeater::make('extra.' . SearchBox::EXTRA_TAXONOMY_LABELS)
|
||||
->schema([
|
||||
Forms\Components\Select::make('torrent_field')->options(SearchBox::getSubCatOptions())->label(__('label.search_box.torrent_field')),
|
||||
Forms\Components\TextInput::make('display_text')->label(__('label.search_box.taxonomy_display_text')),
|
||||
Forms\Components\Section::make(__('label.search_box.taxonomy_display_text'))->schema($displayTextLocalSchema)->columns(count($displayTextLocalSchema)),
|
||||
])
|
||||
->label(__('label.search_box.taxonomies'))->columns(2)
|
||||
->label(__('label.search_box.taxonomies'))
|
||||
->rules([
|
||||
function () {
|
||||
return function (string $attribute, $value, \Closure $fail) {
|
||||
@@ -104,7 +115,7 @@ class SectionResource extends Resource
|
||||
])
|
||||
,
|
||||
]),
|
||||
])->columns(3);
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
@@ -113,8 +124,6 @@ class SectionResource extends Resource
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('name')->label(__('label.search_box.name')),
|
||||
Tables\Columns\TextColumn::make('section_name')->label(__('label.search_box.section_name')),
|
||||
Tables\Columns\BooleanColumn::make('is_default')->label(__('label.search_box.is_default')),
|
||||
Tables\Columns\BooleanColumn::make('showsubcat')->label(__('label.search_box.showsubcat')),
|
||||
Tables\Columns\BooleanColumn::make('showsource'),
|
||||
Tables\Columns\BooleanColumn::make('showmedium'),
|
||||
@@ -139,14 +148,7 @@ class SectionResource extends Resource
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
RelationManagers\CategoriesRelationManager::class,
|
||||
RelationManagers\TaxonomySourcesRelationManager::class,
|
||||
RelationManagers\TaxonomyMediumRelationManager::class,
|
||||
RelationManagers\TaxonomyCodecsRelationManager::class,
|
||||
RelationManagers\TaxonomyAudioCodecsRelationManager::class,
|
||||
RelationManagers\TaxonomyTeamsRelationManager::class,
|
||||
RelationManagers\TaxonomyStandardsRelationManager::class,
|
||||
RelationManagers\TaxonomyProcessingRelationManager::class,
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\System\SectionResource\Pages;
|
||||
|
||||
use App\Filament\Resources\System\SectionResource;
|
||||
use App\Filament\Resources\Section\SectionResource;
|
||||
use App\Models\SearchBox;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\System\SectionResource\Pages;
|
||||
|
||||
use App\Filament\Resources\System\SectionResource;
|
||||
use App\Filament\Resources\Section\SectionResource;
|
||||
use App\Models\SearchBox;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
namespace App\Filament\Resources\System\SectionResource\Pages;
|
||||
|
||||
use App\Filament\PageList;
|
||||
use App\Filament\Resources\System\SectionResource;
|
||||
use App\Filament\Resources\Section\SectionResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section;
|
||||
|
||||
use App\Filament\Resources\Section\SourceResource\Pages;
|
||||
use App\Filament\Resources\Section\SourceResource\RelationManagers;
|
||||
use App\Models\Source;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class SourceResource extends CodecResource
|
||||
{
|
||||
protected static ?string $model = Source::class;
|
||||
|
||||
protected static ?int $navigationSort = 7;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return parent::form($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return parent::table($table);
|
||||
}
|
||||
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListSources::route('/'),
|
||||
'create' => Pages\CreateSource::route('/create'),
|
||||
'edit' => Pages\EditSource::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\SourceResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\SourceResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSource extends CreateRecord
|
||||
{
|
||||
protected static string $resource = SourceResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\SourceResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\SourceResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditSource extends EditRecord
|
||||
{
|
||||
protected static string $resource = SourceResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\SourceResource\Pages;
|
||||
|
||||
use App\Filament\PageList;
|
||||
use App\Filament\Resources\Section\SourceResource;
|
||||
use App\Models\Source;
|
||||
use App\Models\Team;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListSources extends PageList
|
||||
{
|
||||
protected static string $resource = SourceResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getTableQuery(): Builder
|
||||
{
|
||||
return Source::query()->with('search_box')->orderBy('mode', 'asc');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section;
|
||||
|
||||
use App\Filament\Resources\Section\StandardResource\Pages;
|
||||
use App\Filament\Resources\Section\StandardResource\RelationManagers;
|
||||
use App\Models\Standard;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class StandardResource extends CodecResource
|
||||
{
|
||||
protected static ?string $model = Standard::class;
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return parent::form($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return parent::table($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListStandards::route('/'),
|
||||
'create' => Pages\CreateStandard::route('/create'),
|
||||
'edit' => Pages\EditStandard::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\StandardResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\StandardResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateStandard extends CreateRecord
|
||||
{
|
||||
protected static string $resource = StandardResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\StandardResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\StandardResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditStandard extends EditRecord
|
||||
{
|
||||
protected static string $resource = StandardResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\StandardResource\Pages;
|
||||
|
||||
use App\Filament\PageList;
|
||||
use App\Filament\Resources\Section\StandardResource;
|
||||
use App\Models\Codec;
|
||||
use App\Models\Standard;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListStandards extends PageList
|
||||
{
|
||||
protected static string $resource = StandardResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getTableQuery(): Builder
|
||||
{
|
||||
return Standard::query()->with('search_box')->orderBy('mode', 'asc');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section;
|
||||
|
||||
use App\Filament\Resources\Section\TeamResource\Pages;
|
||||
use App\Filament\Resources\Section\TeamResource\RelationManagers;
|
||||
use App\Models\Team;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class TeamResource extends CodecResource
|
||||
{
|
||||
protected static ?string $model = Team::class;
|
||||
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return parent::form($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return parent::table($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListTeams::route('/'),
|
||||
'create' => Pages\CreateTeam::route('/create'),
|
||||
'edit' => Pages\EditTeam::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\TeamResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\TeamResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTeam extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TeamResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\TeamResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Section\TeamResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTeam extends EditRecord
|
||||
{
|
||||
protected static string $resource = TeamResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Section\TeamResource\Pages;
|
||||
|
||||
use App\Filament\PageList;
|
||||
use App\Filament\Resources\Section\TeamResource;
|
||||
use App\Models\Standard;
|
||||
use App\Models\Team;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListTeams extends PageList
|
||||
{
|
||||
protected static string $resource = TeamResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getTableQuery(): Builder
|
||||
{
|
||||
return Team::query()->with('search_box')->orderBy('mode', 'asc');
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,6 @@ class PluginResource extends Resource
|
||||
|
||||
protected static ?int $navigationSort = 99;
|
||||
|
||||
protected static bool $shouldRegisterNavigation = false;
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
return __('admin.sidebar.plugin');
|
||||
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System\SectionResource\RelationManagers;
|
||||
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class TaxonomyAudioCodecsRelationManager extends TaxonomySourcesRelationManager
|
||||
{
|
||||
protected static string $relationship = 'taxonomy_audiocodec';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $torrentField = 'audiocodec';
|
||||
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System\SectionResource\RelationManagers;
|
||||
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class TaxonomyCodecsRelationManager extends TaxonomySourcesRelationManager
|
||||
{
|
||||
protected static string $relationship = 'taxonomy_codec';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $torrentField = 'codec';
|
||||
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System\SectionResource\RelationManagers;
|
||||
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class TaxonomyMediumRelationManager extends TaxonomySourcesRelationManager
|
||||
{
|
||||
protected static string $relationship = 'taxonomy_medium';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $torrentField = 'medium';
|
||||
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System\SectionResource\RelationManagers;
|
||||
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class TaxonomyProcessingRelationManager extends TaxonomySourcesRelationManager
|
||||
{
|
||||
protected static string $relationship = 'taxonomy_processing';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $torrentField = 'processing';
|
||||
|
||||
}
|
||||
-114
@@ -1,114 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System\SectionResource\RelationManagers;
|
||||
|
||||
use App\Filament\Resources\System\SectionResource\TaxonomyTrait;
|
||||
use App\Models\SearchBox;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class TaxonomySourcesRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'taxonomy_source';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $torrentField = 'source';
|
||||
|
||||
protected static function getModelLabel(): string
|
||||
{
|
||||
static $taxonomies;
|
||||
if (!$taxonomies) {
|
||||
$params = request()->all();
|
||||
$taxonomies = $params['serverMemo']['data']['data']['extra'][SearchBox::EXTRA_TAXONOMY_LABELS] ?? [];
|
||||
if (empty($taxonomies)) {
|
||||
$id = request()->route()->parameter('record');
|
||||
if (!$id) {
|
||||
$id = $params['serverMemo']['dataMeta']['models']['ownerRecord']['id'] ?? null;
|
||||
}
|
||||
do_log("searchBox ID: $id");
|
||||
$searchBox = SearchBox::query()->find($id);
|
||||
if ($searchBox) {
|
||||
$taxonomies = $searchBox->extra[SearchBox::EXTRA_TAXONOMY_LABELS] ?? [];
|
||||
} else {
|
||||
$taxonomies = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($taxonomies as $taxonomy) {
|
||||
if ($taxonomy['torrent_field'] == static::$torrentField) {
|
||||
return $taxonomy['display_text'];
|
||||
}
|
||||
}
|
||||
$field = static::$torrentField;
|
||||
return __("label.search_box.$field") ?? $field;
|
||||
}
|
||||
|
||||
public static function shouldShowTaxonomy(SearchBox $searchBox): bool
|
||||
{
|
||||
$taxonomies = $searchBox->extra[SearchBox::EXTRA_TAXONOMY_LABELS] ?? [];
|
||||
foreach ($taxonomies as $taxonomy) {
|
||||
if ($taxonomy['torrent_field'] == static::$torrentField) {
|
||||
do_log("torrent_field: " . static::$torrentField . " should show");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
do_log("torrent_field: " . static::$torrentField . " don't show");
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function canViewForRecord(Model $ownerRecord): bool
|
||||
{
|
||||
return self::shouldShowTaxonomy($ownerRecord);
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')->required(),
|
||||
Forms\Components\TextInput::make('sort_index')
|
||||
->default(0)
|
||||
->label(__('label.search_box.taxonomy.sort_index'))
|
||||
->helperText(__('label.search_box.taxonomy.sort_index_help'))
|
||||
,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id'),
|
||||
Tables\Columns\TextColumn::make('name')->label(__('label.search_box.taxonomy.name')),
|
||||
Tables\Columns\TextColumn::make('sort_index')->label(__('label.search_box.taxonomy.sort_index'))->sortable(),
|
||||
])
|
||||
->defaultSort('sort_index')
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
Tables\Actions\CreateAction::make()->after(function ($record) {
|
||||
clear_search_box_cache($record->mode);
|
||||
}),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make()->after(function ($record) {
|
||||
clear_search_box_cache($record->mode);
|
||||
}),
|
||||
Tables\Actions\DeleteAction::make()->after(function ($record) {
|
||||
clear_search_box_cache($record->mode);
|
||||
}),
|
||||
])
|
||||
->bulkActions([
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System\SectionResource\RelationManagers;
|
||||
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class TaxonomyStandardsRelationManager extends TaxonomySourcesRelationManager
|
||||
{
|
||||
protected static string $relationship = 'taxonomy_standard';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $torrentField = 'standard';
|
||||
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\System\SectionResource\RelationManagers;
|
||||
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class TaxonomyTeamsRelationManager extends TaxonomySourcesRelationManager
|
||||
{
|
||||
protected static string $relationship = 'taxonomy_team';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $torrentField = 'team';
|
||||
|
||||
}
|
||||
@@ -13,4 +13,9 @@ class AudioCodec extends NexusModel
|
||||
{
|
||||
return nexus_trans('searchbox.sub_category_audio_codec_label');
|
||||
}
|
||||
|
||||
public function search_box()
|
||||
{
|
||||
return $this->belongsTo(SearchBox::class, 'mode', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,9 @@ class Category extends NexusModel
|
||||
{
|
||||
return $this->belongsTo(Icon::class, 'icon_id');
|
||||
}
|
||||
|
||||
public function search_box()
|
||||
{
|
||||
return $this->belongsTo(SearchBox::class, 'mode', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,9 @@ class Codec extends NexusModel
|
||||
{
|
||||
return nexus_trans('searchbox.sub_category_codec_label');
|
||||
}
|
||||
|
||||
public function search_box()
|
||||
{
|
||||
return $this->belongsTo(SearchBox::class, 'mode', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,9 @@ class Media extends NexusModel
|
||||
{
|
||||
return nexus_trans('searchbox.sub_category_media_label');
|
||||
}
|
||||
|
||||
public function search_box()
|
||||
{
|
||||
return $this->belongsTo(SearchBox::class, 'mode', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,9 @@ class Processing extends NexusModel
|
||||
{
|
||||
return nexus_trans('searchbox.sub_category_processing_label');
|
||||
}
|
||||
|
||||
public function search_box()
|
||||
{
|
||||
return $this->belongsTo(SearchBox::class, 'mode', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Support\Str;
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class SearchBox extends NexusModel
|
||||
{
|
||||
private static array $instances = [];
|
||||
|
||||
protected $table = 'searchbox';
|
||||
|
||||
protected $fillable = [
|
||||
@@ -21,6 +25,7 @@ class SearchBox extends NexusModel
|
||||
'extra' => 'array',
|
||||
'is_default' => 'boolean',
|
||||
'showsubcat' => 'boolean',
|
||||
'section_name' => 'json',
|
||||
];
|
||||
|
||||
const EXTRA_TAXONOMY_LABELS = 'taxonomy_labels';
|
||||
@@ -40,9 +45,9 @@ class SearchBox extends NexusModel
|
||||
'medium' => 'media',
|
||||
'codec' => 'codecs',
|
||||
'audiocodec' => 'audiocodecs',
|
||||
'team' => 'teams',
|
||||
'standard' => 'standards',
|
||||
'processing' => 'processings'
|
||||
'processing' => 'processings',
|
||||
'team' => 'teams',
|
||||
];
|
||||
|
||||
public static array $extras = [
|
||||
@@ -66,21 +71,23 @@ class SearchBox extends NexusModel
|
||||
foreach ($data['extra'][self::EXTRA_TAXONOMY_LABELS] ?? [] as $item) {
|
||||
if ($field == $item['torrent_field']) {
|
||||
$data["show{$field}"] = 1;
|
||||
$data["extra->" . self::EXTRA_TAXONOMY_LABELS][] = $item;
|
||||
// $data["extra->" . self::EXTRA_TAXONOMY_LABELS][] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
$data["extra->" . self::EXTRA_TAXONOMY_LABELS] = $data['extra'][self::EXTRA_TAXONOMY_LABELS];
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getTaxonomyLabel($torrentField)
|
||||
{
|
||||
$lang = get_langfolder_cookie();
|
||||
foreach ($this->extra[self::EXTRA_TAXONOMY_LABELS] ?? [] as $item) {
|
||||
if ($item['torrent_field'] == $torrentField) {
|
||||
return $item['display_text'];
|
||||
return $item['display_text'][$lang] ?? 'Unknown';
|
||||
}
|
||||
}
|
||||
return nexus_trans('label.torrent.' . $torrentField) ?: ucfirst($torrentField);
|
||||
return nexus_trans("searchbox.sub_category_{$torrentField}_label") ?: ucfirst($torrentField);
|
||||
}
|
||||
|
||||
protected function customFields(): Attribute
|
||||
@@ -111,6 +118,25 @@ class SearchBox extends NexusModel
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function get(int $id)
|
||||
{
|
||||
if (!isset(self::$instances[$id])) {
|
||||
self::$instances[$id] = self::query()->find($id);
|
||||
}
|
||||
return self::$instances[$id];
|
||||
}
|
||||
|
||||
public static function listTaxonomyItems($searchBox, $torrentField): \Illuminate\Support\Collection
|
||||
{
|
||||
if (!$searchBox instanceof self) {
|
||||
$searchBox = self::get(intval($searchBox));
|
||||
}
|
||||
$table = self::$taxonomies[$torrentField];
|
||||
return NexusDB::table($table)->where(function (Builder $query) use ($searchBox) {
|
||||
return $query->where('mode', $searchBox->id)->orWhere('mode', 0);
|
||||
})->get();
|
||||
}
|
||||
|
||||
public function getCustomFieldsAttribute($value): array
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
class SecondIcon extends NexusModel
|
||||
{
|
||||
protected $table = 'secondicons';
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'class_name', 'image', 'mode',
|
||||
'source', 'medium', 'codec', 'audiocodec', 'standard', 'processing', 'team'
|
||||
];
|
||||
|
||||
public static function formatFormData(array $data): array
|
||||
{
|
||||
foreach (SearchBox::$taxonomies as $torrentField => $table) {
|
||||
$mode = $data['mode'];
|
||||
if (empty($data[$torrentField][$mode])) {
|
||||
unset($data[$torrentField]);
|
||||
} else {
|
||||
$data[$torrentField] = $data[$torrentField][$mode];
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function search_box()
|
||||
{
|
||||
return $this->belongsTo(SearchBox::class, 'mode', 'id');
|
||||
}
|
||||
}
|
||||
@@ -11,4 +11,9 @@ class Source extends NexusModel
|
||||
{
|
||||
return nexus_trans('searchbox.sub_category_source_label');
|
||||
}
|
||||
|
||||
public function search_box()
|
||||
{
|
||||
return $this->belongsTo(SearchBox::class, 'mode', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,9 @@ class Standard extends NexusModel
|
||||
{
|
||||
return nexus_trans('searchbox.sub_category_standard_label');
|
||||
}
|
||||
|
||||
public function search_box()
|
||||
{
|
||||
return $this->belongsTo(SearchBox::class, 'mode', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,9 @@ class Team extends NexusModel
|
||||
{
|
||||
return nexus_trans('searchbox.sub_category_team_label');
|
||||
}
|
||||
|
||||
public function search_box()
|
||||
{
|
||||
return $this->belongsTo(SearchBox::class, 'mode', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,23 +2,16 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
use Nexus\Database\NexusDB;
|
||||
>>>>>>> php8
|
||||
|
||||
class TorrentCustomFieldValue extends NexusModel
|
||||
{
|
||||
protected $table = 'torrents_custom_field_values';
|
||||
|
||||
<<<<<<< HEAD
|
||||
protected $fillable = [
|
||||
'torrent_id', 'custom_field_id', 'custom_field_value',
|
||||
];
|
||||
=======
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = ['torrent_id', 'custom_field_id', 'custom_field_value', ];
|
||||
|
||||
>>>>>>> php8
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
'User',
|
||||
'Torrent',
|
||||
'Other',
|
||||
'Section',
|
||||
'System',
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -2,14 +2,18 @@
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Http\Middleware\Locale;
|
||||
use App\Models\Icon;
|
||||
use App\Models\NexusModel;
|
||||
use App\Models\SearchBox;
|
||||
use App\Models\SearchBoxField;
|
||||
use App\Models\SecondIcon;
|
||||
use App\Models\Setting;
|
||||
use Elasticsearch\Endpoints\Search;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Support\Arr;
|
||||
use Nexus\Database\NexusDB;
|
||||
use Filament\Forms;
|
||||
|
||||
class SearchBoxRepository extends BaseRepository
|
||||
{
|
||||
@@ -103,6 +107,8 @@ class SearchBoxRepository extends BaseRepository
|
||||
return Icon::query()->find(array_keys($iconIdArr));
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function migrateToModeRelated()
|
||||
{
|
||||
$secondIconTable = 'secondicons';
|
||||
@@ -112,25 +118,25 @@ class SearchBoxRepository extends BaseRepository
|
||||
$tables = array_values(SearchBox::$taxonomies);
|
||||
|
||||
foreach ($searchBoxList as $searchBox) {
|
||||
if ($searchBox->id == $normalId) {
|
||||
//all sub categories add `mode` field
|
||||
foreach ($tables as $table) {
|
||||
NexusDB::table($table)->update(['mode' => $normalId]);
|
||||
do_log("update table $table mode = $normalId");
|
||||
}
|
||||
//also second icons
|
||||
NexusDB::table($secondIconTable)->update(['mode' => $normalId]);
|
||||
do_log("update table $secondIconTable mode = $normalId");
|
||||
} elseif ($searchBox->id == $specialId && $specialId != $normalId) {
|
||||
//copy from normal section
|
||||
foreach ($tables as $table) {
|
||||
$sql = sprintf(
|
||||
"insert into `%s` (name, sort_index, mode) select name, sort_index, '%s' from `%s`",
|
||||
$table, $specialId, $table
|
||||
);
|
||||
NexusDB::statement($sql);
|
||||
do_log("copy table $table, $sql");
|
||||
}
|
||||
// if ($searchBox->id == $normalId) {
|
||||
// //all sub categories add `mode` field
|
||||
// foreach ($tables as $table) {
|
||||
// NexusDB::table($table)->update(['mode' => $normalId]);
|
||||
// do_log("update table $table mode = $normalId");
|
||||
// }
|
||||
// //also second icons
|
||||
// NexusDB::table($secondIconTable)->update(['mode' => $normalId]);
|
||||
// do_log("update table $secondIconTable mode = $normalId");
|
||||
// } elseif ($searchBox->id == $specialId && $specialId != $normalId) {
|
||||
// //copy from normal section
|
||||
// foreach ($tables as $table) {
|
||||
// $sql = sprintf(
|
||||
// "insert into `%s` (name, sort_index, mode) select name, sort_index, '%s' from `%s`",
|
||||
// $table, $specialId, $table
|
||||
// );
|
||||
// NexusDB::statement($sql);
|
||||
// do_log("copy table $table, $sql");
|
||||
// }
|
||||
// $fields = array_keys(SearchBox::$taxonomies);
|
||||
// $fields = array_merge($fields, ['name', 'class_name', 'image']);
|
||||
// $fieldStr = implode(', ', $fields);
|
||||
@@ -140,47 +146,152 @@ class SearchBoxRepository extends BaseRepository
|
||||
// );
|
||||
// NexusDB::statement($sql);
|
||||
// do_log("copy table $secondIconTable, $sql");
|
||||
}
|
||||
// }
|
||||
$taxonomies = [];
|
||||
foreach (SearchBox::$taxonomies as $field => $taxonomyTable) {
|
||||
$showField = "show" . $field;
|
||||
if ($searchBox->{$showField}) {
|
||||
foreach (SearchBox::$taxonomies as $torrentField => $taxonomyTable) {
|
||||
$searchBoxField = "show" . $torrentField;
|
||||
if ($searchBox->showsubcat && $searchBox->{$searchBoxField}) {
|
||||
$taxonomies[] = [
|
||||
'torrent_field' => $field,
|
||||
'display_text' => $field,
|
||||
'torrent_field' => $torrentField,
|
||||
'display_text' => [
|
||||
'en' => nexus_trans("searchbox.sub_category_{$torrentField}_label", [], Locale::$languageMaps['en']),
|
||||
'chs' => nexus_trans("searchbox.sub_category_{$torrentField}_label", [], Locale::$languageMaps['chs']),
|
||||
'cht' => nexus_trans("searchbox.sub_category_{$torrentField}_label", [], Locale::$languageMaps['cht']),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
$searchBox->update(["extra->" . SearchBox::EXTRA_TAXONOMY_LABELS => $taxonomies]);
|
||||
if (!empty($taxonomies)) {
|
||||
$searchBox->update(["extra->" . SearchBox::EXTRA_TAXONOMY_LABELS => $taxonomies]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function renderQualitySelect($searchBox, array $torrentInfo = []): string
|
||||
public function renderTaxonomySelect($searchBox, array $torrentInfo = []): string
|
||||
{
|
||||
if (!$searchBox instanceof SearchBox) {
|
||||
$searchBox = SearchBox::query()->findOrFail(intval($searchBox));
|
||||
$searchBox = SearchBox::get(intval($searchBox));
|
||||
}
|
||||
$results = [];
|
||||
foreach (SearchBox::$taxonomies as $torrentField => $table) {
|
||||
$searchBoxField = "show" . $torrentField;
|
||||
if ($searchBox->{$searchBoxField}) {
|
||||
$select = sprintf("<b>%s:</b>", $searchBox->getTaxonomyLabel($torrentField));
|
||||
$select .= sprintf('<select name="%s" data-mode="%s">', $torrentField . "_sel", $searchBox->id);
|
||||
$select .= sprintf('<option value="%s">%s</option>', 0, nexus_trans('nexus.select_one_please'));
|
||||
$relation = "taxonomy_$torrentField";
|
||||
$list = $searchBox->{$relation};
|
||||
foreach ($list as $item) {
|
||||
$selected = '';
|
||||
if (isset($torrentInfo[$torrentField]) && $torrentInfo[$torrentField] == $item->id) {
|
||||
$selected = " selected";
|
||||
}
|
||||
$select .= sprintf('<option value="%s"%s>%s</option>', $item->id, $selected, $item->name);
|
||||
//Keep the order
|
||||
if (!empty($searchBox->extra[SearchBox::EXTRA_TAXONOMY_LABELS])) {
|
||||
foreach ($searchBox->extra[SearchBox::EXTRA_TAXONOMY_LABELS] as $taxonomy) {
|
||||
$select = $this->buildTaxonomySelect($searchBox, $taxonomy['torrent_field'], $torrentInfo);
|
||||
if ($select) {
|
||||
$results[] = $select;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (SearchBox::$taxonomies as $torrentField => $table) {
|
||||
$select = $this->buildTaxonomySelect($searchBox, $torrentField, $torrentInfo);
|
||||
if ($select) {
|
||||
$results[] = $select;
|
||||
}
|
||||
$select .= '</select>';
|
||||
$results[] = $select;
|
||||
}
|
||||
}
|
||||
|
||||
return implode(' ', $results);
|
||||
}
|
||||
|
||||
public function listTaxonomyInfo($searchBox, array $torrentWithTaxonomy): array
|
||||
{
|
||||
if (!$searchBox instanceof SearchBox) {
|
||||
$searchBox = SearchBox::get(intval($searchBox));
|
||||
}
|
||||
$results = [];
|
||||
//Keep the order
|
||||
if (!empty($searchBox->extra[SearchBox::EXTRA_TAXONOMY_LABELS])) {
|
||||
foreach ($searchBox->extra[SearchBox::EXTRA_TAXONOMY_LABELS] as $item) {
|
||||
$taxonomy = $this->getTaxonomyInfo($searchBox, $torrentWithTaxonomy, $item['torrent_field']);
|
||||
if ($taxonomy) {
|
||||
$results[] = $taxonomy;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (SearchBox::$taxonomies as $torrentField => $table) {
|
||||
$taxonomy = $this->getTaxonomyInfo($searchBox, $torrentWithTaxonomy, $torrentField);
|
||||
if ($taxonomy) {
|
||||
$results[] = $taxonomy;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
private function getTaxonomyInfo(SearchBox $searchBox, array $torrentWithTaxonomy, $torrentField)
|
||||
{
|
||||
$searchBoxField = "show" . $torrentField;
|
||||
$torrentTaxonomyField = $torrentField . "_name";
|
||||
if ($searchBox->showsubcat && $searchBox->{$searchBoxField} && !empty($torrentWithTaxonomy[$torrentTaxonomyField])) {
|
||||
return [
|
||||
'field' => $torrentField,
|
||||
'label' => $searchBox->getTaxonomyLabel($torrentField),
|
||||
'value' => $torrentWithTaxonomy[$torrentTaxonomyField],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
private function buildTaxonomySelect(SearchBox $searchBox, $torrentField, array $torrentInfo)
|
||||
{
|
||||
$searchBoxId = $searchBox->id;
|
||||
$searchBoxField = "show" . $torrentField;
|
||||
if ($searchBox->showsubcat && $searchBox->{$searchBoxField}) {
|
||||
$table = SearchBox::$taxonomies[$torrentField];
|
||||
$select = sprintf("<b>%s: </b>", $searchBox->getTaxonomyLabel($torrentField));
|
||||
$select .= sprintf('<select name="%s_sel[%s]" data-mode="%s_%s">',$torrentField, $searchBoxId, $torrentField, $searchBoxId);
|
||||
$select .= sprintf('<option value="%s">%s</option>', 0, nexus_trans('nexus.select_one_please'));
|
||||
$list = NexusDB::table($table)->where(function (Builder $query) use ($searchBox) {
|
||||
return $query->where('mode', $searchBox->id)->orWhere('mode', 0);
|
||||
})->get();
|
||||
foreach ($list as $item) {
|
||||
$selected = '';
|
||||
if (isset($torrentInfo[$torrentField]) && $torrentInfo[$torrentField] == $item->id) {
|
||||
$selected = " selected";
|
||||
}
|
||||
$select .= sprintf('<option value="%s"%s>%s</option>', $item->id, $selected, $item->name);
|
||||
}
|
||||
$select .= '</select>';
|
||||
return $select;
|
||||
}
|
||||
}
|
||||
|
||||
public function listTaxonomyFormSchema($searchBox): array
|
||||
{
|
||||
if (!$searchBox instanceof SearchBox) {
|
||||
$searchBox = SearchBox::get(intval($searchBox));
|
||||
}
|
||||
$results = [];
|
||||
//Keep the order
|
||||
if (!empty($searchBox->extra[SearchBox::EXTRA_TAXONOMY_LABELS])) {
|
||||
foreach ($searchBox->extra[SearchBox::EXTRA_TAXONOMY_LABELS] as $taxonomy) {
|
||||
$select = $this->buildTaxonomyFormSchema($searchBox, $taxonomy['torrent_field']);
|
||||
if ($select) {
|
||||
$results[] = $select;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (SearchBox::$taxonomies as $torrentField => $table) {
|
||||
$select = $this->buildTaxonomyFormSchema($searchBox, $torrentField);
|
||||
if ($select) {
|
||||
$results[] = $select;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
private function buildTaxonomyFormSchema(SearchBox $searchBox, $torrentField)
|
||||
{
|
||||
$searchBoxId = $searchBox->id;
|
||||
$searchBoxField = "show" . $torrentField;
|
||||
$name = sprintf('%s.%s', $torrentField, $searchBoxId);
|
||||
if ($searchBox->showsubcat && $searchBox->{$searchBoxField}) {
|
||||
$items = SearchBox::listTaxonomyItems($searchBox, $torrentField);
|
||||
return Forms\Components\Select::make($name)
|
||||
->options($items->pluck('name', 'id')->toArray())
|
||||
->label($searchBox->getTaxonomyLabel($torrentField));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user