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
+17
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');