From 9ace9220484fa01557beaa64b0b79d8ba448b1c3 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Fri, 1 Dec 2023 09:41:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20app/Models/Keyword.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Keyword.php | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/app/Models/Keyword.php b/app/Models/Keyword.php index 1905fb8..e94bffd 100644 --- a/app/Models/Keyword.php +++ b/app/Models/Keyword.php @@ -6,13 +6,14 @@ use App\Casts\StorageFile; use EloquentFilter\Filterable; use Illuminate\Database\Eloquent\Model; use App\Traits\HasDateTimeFormatter; +use App\Traits\TreePath; /** * 字典表 */ class Keyword extends Model { - use Filterable, HasDateTimeFormatter; + use Filterable, HasDateTimeFormatter, TreePath; protected $fillable = ['id', 'name', 'key', 'value', 'parent_id', 'path', 'sort', 'level', 'options', 'image', 'description', 'content']; @@ -20,19 +21,4 @@ class Keyword extends Model 'options' => 'array', 'image' => StorageFile::class, ]; - - public function parent() - { - return $this->belongsTo(static::class, 'parent_id'); - } - - public function children() - { - return $this->hasMany(static::class, 'parent_id'); - } - - public function scopeSort($q) - { - return $q->orderByDesc('sort'); - } }