custom fields add priority + display

This commit is contained in:
xiaomlove
2022-09-19 16:27:04 +08:00
parent a9c734e45b
commit b305ce7380
20 changed files with 225 additions and 72 deletions

View File

@@ -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');

View 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'];
}

View 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', ];
}