mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
custom fields add priority + display
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
|
||||
class SearchBox extends NexusModel
|
||||
{
|
||||
protected $table = 'searchbox';
|
||||
@@ -33,6 +35,21 @@ class SearchBox extends NexusModel
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getCustomFieldsAttribute($value): array
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
return explode(',', $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function setCustomFieldsAttribute($value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$this->attributes['custom_fields'] = implode(',', $value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function categories(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(Category::class, 'mode');
|
||||
|
||||
15
app/Models/TorrentCustomField.php
Normal file
15
app/Models/TorrentCustomField.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class TorrentCustomField extends NexusModel
|
||||
{
|
||||
protected $table = 'torrents_custom_fields';
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = ['name', 'label', 'type', 'required', 'is_single_row', 'options', 'help', 'display', 'priority'];
|
||||
|
||||
}
|
||||
15
app/Models/TorrentCustomFieldValue.php
Normal file
15
app/Models/TorrentCustomFieldValue.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class TorrentCustomFieldValue extends NexusModel
|
||||
{
|
||||
protected $table = 'torrents_custom_field_values';
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = ['torrent_id', 'custom_field_id', 'custom_field_value', ];
|
||||
|
||||
}
|
||||
@@ -25,11 +25,12 @@ class BaseRepository
|
||||
$canViewAnonymousClass = Setting::get('authority.viewanonymous');
|
||||
if($user->privacy == "strong" || ($torrent && $torrent->anonymous == 'yes' && $user->id == $torrent->owner)) {
|
||||
//用户强私密,或者种子作者匿名而当前项作者刚好为种子作者
|
||||
$anonymousText = nexus_trans('label.anonymous');
|
||||
if($authenticator->class >= $canViewAnonymousClass || $user->id == $authenticator->id) {
|
||||
//但当前用户权限可以查看匿名者,或当前用户查看自己的数据,显示个匿名,后边加真实用户名
|
||||
return sprintf('匿名(%s)', $username);
|
||||
return sprintf('%s(%s)', $anonymousText, $username);
|
||||
} else {
|
||||
return '匿名';
|
||||
return $anonymousText;
|
||||
}
|
||||
} else {
|
||||
return $username;
|
||||
|
||||
Reference in New Issue
Block a user