searchbox label

This commit is contained in:
xiaomlove
2021-06-21 19:56:25 +08:00
parent ba90132f78
commit e19aaafc6c
12 changed files with 113 additions and 24 deletions
+5
View File
@@ -6,4 +6,9 @@ namespace App\Models;
class AudioCodec extends NexusModel class AudioCodec extends NexusModel
{ {
protected $table = 'audiocodecs'; protected $table = 'audiocodecs';
public static function getLabelName()
{
return nexus_trans('searchbox.sub_category_audio_codec_label');
}
} }
+5
View File
@@ -9,6 +9,11 @@ class Category extends NexusModel
protected $fillable = ['mode', 'name', 'class_name', 'image', 'sort_index', 'icon_id']; protected $fillable = ['mode', 'name', 'class_name', 'image', 'sort_index', 'icon_id'];
public static function getLabelName()
{
return nexus_trans('searchbox.category_label');
}
public function icon(): \Illuminate\Database\Eloquent\Relations\BelongsTo public function icon(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Icon::class, 'icon_id'); return $this->belongsTo(Icon::class, 'icon_id');
+5
View File
@@ -6,4 +6,9 @@ namespace App\Models;
class Codec extends NexusModel class Codec extends NexusModel
{ {
protected $table = 'codecs'; protected $table = 'codecs';
public static function getLabelName()
{
return nexus_trans('searchbox.sub_category_codec_label');
}
} }
+5
View File
@@ -6,4 +6,9 @@ namespace App\Models;
class Media extends NexusModel class Media extends NexusModel
{ {
protected $table = 'media'; protected $table = 'media';
public static function getLabelName()
{
return nexus_trans('searchbox.sub_category_media_label');
}
} }
+5
View File
@@ -6,4 +6,9 @@ namespace App\Models;
class Processing extends NexusModel class Processing extends NexusModel
{ {
protected $table = 'processings'; protected $table = 'processings';
public static function getLabelName()
{
return nexus_trans('searchbox.sub_category_processing_label');
}
} }
+4
View File
@@ -5,4 +5,8 @@ namespace App\Models;
class Source extends NexusModel class Source extends NexusModel
{ {
public static function getLabelName()
{
return nexus_trans('searchbox.sub_category_source_label');
}
} }
+4 -1
View File
@@ -5,5 +5,8 @@ namespace App\Models;
class Standard extends NexusModel class Standard extends NexusModel
{ {
public static function getLabelName()
{
return nexus_trans('searchbox.sub_standard_source_label');
}
} }
+4 -1
View File
@@ -5,5 +5,8 @@ namespace App\Models;
class Team extends NexusModel class Team extends NexusModel
{ {
public static function getLabelName()
{
return nexus_trans('searchbox.sub_category_team_label');
}
} }
+40 -22
View File
@@ -11,6 +11,8 @@ use App\Models\Media;
use App\Models\Message; use App\Models\Message;
use App\Models\Peer; use App\Models\Peer;
use App\Models\Processing; use App\Models\Processing;
use App\Models\SearchBox;
use App\Models\Setting;
use App\Models\Snatch; use App\Models\Snatch;
use App\Models\Source; use App\Models\Source;
use App\Models\Standard; use App\Models\Standard;
@@ -80,34 +82,50 @@ class TorrentRepository extends BaseRepository
return $torrents; return $torrents;
} }
public function getSearchBox() public function getSearchBox($id = null)
{ {
$category = Category::query()->orderBy('sort_index')->orderBy('id')->get(); if (is_null($id)) {
$source = Source::query()->orderBy('sort_index')->orderBy('id')->get(); $id = Setting::get('main.browsecat');
$media = Media::query()->orderBy('sort_index')->orderBy('id')->get(); }
$codec = Codec::query()->orderBy('sort_index')->orderBy('id')->get(); $searchBox = SearchBox::query()->findOrFail($id);
$standard = Standard::query()->orderBy('sort_index')->orderBy('id')->get(); $category = $searchBox->categories()->orderBy('sort_index')->orderBy('id')->get();
$processing = Processing::query()->orderBy('sort_index')->orderBy('id')->get();
$team = Team::query()->orderBy('sort_index')->orderBy('id')->get();
$audioCodec = AudioCodec::query()->orderBy('sort_index')->orderBy('id')->get();
$modalRows = []; $modalRows = [];
$modalRows[] = $categoryFormatted = $this->formatRow('类型', $category, 'category'); $modalRows[] = $categoryFormatted = $this->formatRow(Category::getLabelName(), $category, 'category');
$modalRows[] = $this->formatRow('媒介', $source, 'source'); if ($searchBox->showsubcat) {
$modalRows[] = $this->formatRow('媒介', $media, 'medium'); if ($searchBox->showsource) {
$modalRows[] = $this->formatRow('编码', $codec, 'codec'); $source = Source::query()->orderBy('sort_index')->orderBy('id')->get();
$modalRows[] = $this->formatRow('音频编码', $audioCodec, 'audio_codec'); $modalRows[] = $this->formatRow(Source::getLabelName(), $source, 'source');
$modalRows[] = $this->formatRow('分辨率', $standard, 'standard'); }
$modalRows[] = $this->formatRow('处理', $processing, 'processing'); if ($searchBox->showmedia) {
$modalRows[] = $this->formatRow('制作组', $team, 'team'); $media = Media::query()->orderBy('sort_index')->orderBy('id')->get();
$modalRows[] = $this->formatRow(Media::getLabelName(), $media, 'medium');
}
if ($searchBox->showcodec) {
$codec = Codec::query()->orderBy('sort_index')->orderBy('id')->get();
$modalRows[] = $this->formatRow(Codec::getLabelName(), $codec, 'codec');
}
if ($searchBox->showstandard) {
$standard = Standard::query()->orderBy('sort_index')->orderBy('id')->get();
$modalRows[] = $this->formatRow(Standard::getLabelName(), $standard, 'standard');
}
if ($searchBox->showprocessing) {
$processing = Processing::query()->orderBy('sort_index')->orderBy('id')->get();
$modalRows[] = $this->formatRow(Processing::getLabelName(), $processing, 'processing');
}
if ($searchBox->showteam) {
$team = Team::query()->orderBy('sort_index')->orderBy('id')->get();
$modalRows[] = $this->formatRow(Team::getLabelName(), $team, 'team');
}
if ($searchBox->showaudiocodec) {
$audioCodec = AudioCodec::query()->orderBy('sort_index')->orderBy('id')->get();
$modalRows[] = $this->formatRow(AudioCodec::getLabelName(), $audioCodec, 'audio_codec');
}
}
$results = []; $results = [];
$categories = $categoryFormatted['rows']; $categories = $categoryFormatted['rows'];
$categories[0]['active'] = 1; $categories[0]['active'] = 1;
$results['categories'] = $categories; $results['categories'] = $categories;
$results['modal_rows'] = $modalRows; $results['modal_rows'] = $modalRows;
return $results; return $results;
} }
@@ -115,7 +133,7 @@ class TorrentRepository extends BaseRepository
{ {
$result['header'] = $header; $result['header'] = $header;
$result['rows'][] = [ $result['rows'][] = [
'label' => '全部', 'label' => 'All',
'value' => 0, 'value' => 0,
'name' => $name, 'name' => $name,
'active' => 1, 'active' => 1,
+12
View File
@@ -0,0 +1,12 @@
<?php
return [
'category_label' => 'Category',
'sub_category_source_label' => 'Source',
'sub_category_media_label' => 'Media',
'sub_category_standard_label' => 'Standard',
'sub_category_team_label' => 'Team',
'sub_category_processing_label' => 'Processing',
'sub_category_codec_label' => 'Codec',
'sub_category_audio_codec_label' => 'AudioCodec',
];
+12
View File
@@ -0,0 +1,12 @@
<?php
return [
'category_label' => '分类',
'sub_category_source_label' => '来源',
'sub_category_media_label' => '媒介',
'sub_category_standard_label' => '分辨率',
'sub_category_team_label' => '制作组',
'sub_category_processing_label' => '处理',
'sub_category_codec_label' => '编码',
'sub_category_audio_codec_label' => '音频编码',
];
+12
View File
@@ -0,0 +1,12 @@
<?php
return [
'category_label' => '分類',
'sub_category_source_label' => '來源',
'sub_category_media_label' => '媒介',
'sub_category_standard_label' => '分辨率',
'sub_category_team_label' => '製作組',
'sub_category_processing_label' => '處理',
'sub_category_codec_label' => '編碼',
'sub_category_audio_codec_label' => '音頻編碼',
];