mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40: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', ];
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user